diff --git a/examples/petstore-expanded/strict/api/petstore-server.gen.go b/examples/petstore-expanded/strict/api/petstore-server.gen.go index b229efd2b5..21959a72a0 100644 --- a/examples/petstore-expanded/strict/api/petstore-server.gen.go +++ b/examples/petstore-expanded/strict/api/petstore-server.gen.go @@ -370,13 +370,13 @@ type StrictHandlerFunc func(ctx context.Context, w http.ResponseWriter, r *http. type StrictMiddlewareFunc func(f StrictHandlerFunc, operationID string) StrictHandlerFunc -type StrictChiServerOptions struct { +type StrictHTTPServerOptions struct { RequestErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) } func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface { - return &strictHandler{ssi: ssi, middlewares: middlewares, options: StrictChiServerOptions{ + return &strictHandler{ssi: ssi, middlewares: middlewares, options: StrictHTTPServerOptions{ RequestErrorHandlerFunc: func(w http.ResponseWriter, r *http.Request, err error) { http.Error(w, err.Error(), http.StatusBadRequest) }, @@ -386,14 +386,14 @@ func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareF }} } -func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictChiServerOptions) ServerInterface { +func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictHTTPServerOptions) ServerInterface { return &strictHandler{ssi: ssi, middlewares: middlewares, options: options} } type strictHandler struct { ssi StrictServerInterface middlewares []StrictMiddlewareFunc - options StrictChiServerOptions + options StrictHTTPServerOptions } // FindPets operation middleware diff --git a/internal/test/strict-server/chi/server.gen.go b/internal/test/strict-server/chi/server.gen.go index a40b60320d..b2ddfac44e 100644 --- a/internal/test/strict-server/chi/server.gen.go +++ b/internal/test/strict-server/chi/server.gen.go @@ -597,13 +597,13 @@ type StrictHandlerFunc func(ctx context.Context, w http.ResponseWriter, r *http. type StrictMiddlewareFunc func(f StrictHandlerFunc, operationID string) StrictHandlerFunc -type StrictChiServerOptions struct { +type StrictHTTPServerOptions struct { RequestErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) } func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface { - return &strictHandler{ssi: ssi, middlewares: middlewares, options: StrictChiServerOptions{ + return &strictHandler{ssi: ssi, middlewares: middlewares, options: StrictHTTPServerOptions{ RequestErrorHandlerFunc: func(w http.ResponseWriter, r *http.Request, err error) { http.Error(w, err.Error(), http.StatusBadRequest) }, @@ -613,14 +613,14 @@ func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareF }} } -func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictChiServerOptions) ServerInterface { +func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictHTTPServerOptions) ServerInterface { return &strictHandler{ssi: ssi, middlewares: middlewares, options: options} } type strictHandler struct { ssi StrictServerInterface middlewares []StrictMiddlewareFunc - options StrictChiServerOptions + options StrictHTTPServerOptions } // JSONExample operation middleware diff --git a/pkg/codegen/operations.go b/pkg/codegen/operations.go index b191532073..f881b1426f 100644 --- a/pkg/codegen/operations.go +++ b/pkg/codegen/operations.go @@ -911,8 +911,8 @@ func GenerateGorillaServer(t *template.Template, operations []OperationDefinitio func GenerateStrictServer(t *template.Template, operations []OperationDefinition, opts Configuration) (string, error) { templates := []string{"strict/strict-interface.tmpl"} - if opts.Generate.ChiServer { - templates = append(templates, "strict/strict-chi.tmpl") + if opts.Generate.ChiServer || opts.Generate.GorillaServer { + templates = append(templates, "strict/strict-http.tmpl") } if opts.Generate.EchoServer { templates = append(templates, "strict/strict-echo.tmpl") diff --git a/pkg/codegen/templates/strict/strict-chi.tmpl b/pkg/codegen/templates/strict/strict-http.tmpl similarity index 97% rename from pkg/codegen/templates/strict/strict-chi.tmpl rename to pkg/codegen/templates/strict/strict-http.tmpl index c8465db02b..c6269aa0ab 100644 --- a/pkg/codegen/templates/strict/strict-chi.tmpl +++ b/pkg/codegen/templates/strict/strict-http.tmpl @@ -2,13 +2,13 @@ type StrictHandlerFunc func(ctx context.Context, w http.ResponseWriter, r *http. type StrictMiddlewareFunc func(f StrictHandlerFunc, operationID string) StrictHandlerFunc -type StrictChiServerOptions struct { +type StrictHTTPServerOptions struct { RequestErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) ResponseErrorHandlerFunc func(w http.ResponseWriter, r *http.Request, err error) } func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc) ServerInterface { - return &strictHandler{ssi: ssi, middlewares: middlewares, options: StrictChiServerOptions { + return &strictHandler{ssi: ssi, middlewares: middlewares, options: StrictHTTPServerOptions { RequestErrorHandlerFunc: func(w http.ResponseWriter, r *http.Request, err error) { http.Error(w, err.Error(), http.StatusBadRequest) }, @@ -18,14 +18,14 @@ func NewStrictHandler(ssi StrictServerInterface, middlewares []StrictMiddlewareF }} } -func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictChiServerOptions) ServerInterface { +func NewStrictHandlerWithOptions(ssi StrictServerInterface, middlewares []StrictMiddlewareFunc, options StrictHTTPServerOptions) ServerInterface { return &strictHandler{ssi: ssi, middlewares: middlewares, options: options} } type strictHandler struct { ssi StrictServerInterface middlewares []StrictMiddlewareFunc - options StrictChiServerOptions + options StrictHTTPServerOptions } {{range .}}