[Go][Server] minor enhancement to the template (#4417)

* minor enhancement to the go server template

* update samples
This commit is contained in:
William Cheng 2019-11-09 11:24:12 +08:00 committed by GitHub
parent 777e39007a
commit db729be7df
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
7 changed files with 38 additions and 37 deletions

View File

@ -7,9 +7,9 @@ import (
"net/http"
"os"
"strconv"
{{#featureCORS}}
"github.com/gorilla/handlers"{{/featureCORS}}
{{#featureCORS}}
"github.com/gorilla/handlers"
{{/featureCORS}}
"github.com/gorilla/mux"
)
@ -36,8 +36,10 @@ func NewRouter(routers ...Router) *mux.Router {
for _, route := range api.Routes() {
var handler http.Handler
handler = route.HandlerFunc
handler = Logger(handler, route.Name){{#featureCORS}}
handler = handlers.CORS()(handler){{/featureCORS}}
handler = Logger(handler, route.Name)
{{#featureCORS}}
handler = handlers.CORS()(handler)
{{/featureCORS}}
router.
Methods(route.Method).

View File

@ -15,7 +15,6 @@ import (
"net/http"
"os"
"strconv"
"github.com/gorilla/mux"
)