M generator.go +1 -3
@@ 95,9 95,7 @@ func generateFunc(api Api, op Operation,
genDelete(api, op, out)
out <- "\treturn nil"
case "PATCH":
- // FIXME
- out <- "\t// IMPLEMENT PATCH, YOU SILLY GOOSE"
- out <- "\treturn nil, nil"
+ genPatch(api, op, out)
case "POST":
genPost(api, op, out)
case "PUT":
A => patch.go +5 -0
@@ 0,0 1,5 @@
+package sashay
+
+func genPatch(api Api, op Operation, out chan string) {
+ genPostBase(api, op, out)
+}
M post.go +7 -2
@@ 9,6 9,7 @@ func genPostBase(api Api, op Operation,
rv := ""
zero := ""
if op.Type != "void" {
+ out <- fmt.Sprintf("\trv := %s", op.zero())
rv = "rv, "
zero = op.zero() + ", "
}
@@ 39,7 40,7 @@ func genPostBase(api Api, op Operation,
hasBody = true
out <- fmt.Sprintf("\tb, e := json.Marshal(%s)", p.Name)
out <- "\tif e != nil {"
- out <- "\t\treturn e"
+ out <- fmt.Sprintf("\t\treturn %se", rv)
out <- "\t}"
}
} else {
@@ 75,7 76,11 @@ func genPostBase(api Api, op Operation,
out <- "\tif resp.StatusCode >= 500 && resp.StatusCode < 600 {"
out <- fmt.Sprintf("\t\treturn %serrors.New(\"Internal server error\")", rv)
out <- "\t}"
- out <- "\treturn nil"
+ if op.Type != "void" {
+ genDeserialize(op, out)
+ } else {
+ out <- "return nil"
+ }
}
func genPost(api Api, op Operation, out chan string) {