forked from loafle/openapi-generator-original
[Go][Server] minor enhancement to the template (#4417)
* minor enhancement to the go server template * update samples
This commit is contained in:
parent
777e39007a
commit
db729be7df
@ -7,9 +7,9 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
{{#featureCORS}}
|
{{#featureCORS}}
|
||||||
|
"github.com/gorilla/handlers"
|
||||||
"github.com/gorilla/handlers"{{/featureCORS}}
|
{{/featureCORS}}
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -36,8 +36,10 @@ func NewRouter(routers ...Router) *mux.Router {
|
|||||||
for _, route := range api.Routes() {
|
for _, route := range api.Routes() {
|
||||||
var handler http.Handler
|
var handler http.Handler
|
||||||
handler = route.HandlerFunc
|
handler = route.HandlerFunc
|
||||||
handler = Logger(handler, route.Name){{#featureCORS}}
|
handler = Logger(handler, route.Name)
|
||||||
handler = handlers.CORS()(handler){{/featureCORS}}
|
{{#featureCORS}}
|
||||||
|
handler = handlers.CORS()(handler)
|
||||||
|
{{/featureCORS}}
|
||||||
|
|
||||||
router.
|
router.
|
||||||
Methods(route.Method).
|
Methods(route.Method).
|
||||||
|
@ -15,7 +15,6 @@ import (
|
|||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
|
||||||
"github.com/gorilla/mux"
|
"github.com/gorilla/mux"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user