[Go-server] Fix formatting of go-server generated code (#7162)

* Add missing go-server petstore batch script

* Make go-server confirm to gofmt
This commit is contained in:
Ben Wells
2017-12-14 16:04:48 +00:00
committed by William Cheng
parent e70bdf17f2
commit 2e348b27f7
14 changed files with 66 additions and 74 deletions

View File

@@ -6,14 +6,9 @@ import (
)
type {{classname}} struct {
}{{#operation}}
}
{{#operation}}
func {{nickname}}(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}
{{/operation}}
{{/operations}}
w.Header().Set("Content-Type", "application/json; charset=UTF-8")
w.WriteHeader(http.StatusOK)
}{{/operation}}{{/operations}}

View File

@@ -20,4 +20,4 @@ func Logger(inner http.Handler, name string) http.Handler {
time.Since(start),
)
})
}
}

View File

@@ -1,6 +1,9 @@
package main
import (
"log"
"net/http"
// WARNING!
// Change this to a fully-qualified import path
// once you place this file into your project.
@@ -9,14 +12,12 @@ import (
// sw "github.com/myname/myrepo/{{apiPath}}"
//
sw "./{{apiPath}}"
"log"
"net/http"
)
func main() {
log.Printf("Server started")
router := sw.NewRouter()
log.Fatal(http.ListenAndServe(":{{serverPort}}", router))
}

View File

@@ -1,8 +1,9 @@
package {{packageName}}
import (
"net/http"
"fmt"
"net/http"
"github.com/gorilla/mux"
)
@@ -42,13 +43,12 @@ var routes = Routes{
"GET",
"{{{basePathWithoutHost}}}/",
Index,
},
{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
},{{#apiInfo}}{{#apis}}{{#operations}}{{#operation}}
Route{
"{{operationId}}",
"{{httpMethod}}",
"{{{basePathWithoutHost}}}{{{path}}}",
{{operationId}},
},
{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
},{{/operation}}{{/operations}}{{/apis}}{{/apiInfo}}
}