Skip to content

Commit 00c6e0a

Browse files
Jesse Michaelwing328
authored andcommitted
Return Router interface from controller constructor. (#4196)
Update the go server api controller template to return the Router interface instead of the api specific router. The Router interface type has the Routes function, which is what the generated `NewRouter` function needs. (not the api specific interface).
1 parent 9fe2f4d commit 00c6e0a

File tree

4 files changed

+4
-4
lines changed

4 files changed

+4
-4
lines changed

modules/openapi-generator/src/main/resources/go-server/controller-api.mustache

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type {{classname}}Controller struct {
1515
}
1616

1717
// New{{classname}}Controller creates a default api controller
18-
func New{{classname}}Controller(s {{classname}}Servicer) {{classname}}Router {
18+
func New{{classname}}Controller(s {{classname}}Servicer) Router {
1919
return &{{classname}}Controller{ service: s }
2020
}
2121

samples/server/petstore/go-api-server/go/api_pet.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type PetApiController struct {
2323
}
2424

2525
// NewPetApiController creates a default api controller
26-
func NewPetApiController(s PetApiServicer) PetApiRouter {
26+
func NewPetApiController(s PetApiServicer) Router {
2727
return &PetApiController{ service: s }
2828
}
2929

samples/server/petstore/go-api-server/go/api_store.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type StoreApiController struct {
2323
}
2424

2525
// NewStoreApiController creates a default api controller
26-
func NewStoreApiController(s StoreApiServicer) StoreApiRouter {
26+
func NewStoreApiController(s StoreApiServicer) Router {
2727
return &StoreApiController{ service: s }
2828
}
2929

samples/server/petstore/go-api-server/go/api_user.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ type UserApiController struct {
2323
}
2424

2525
// NewUserApiController creates a default api controller
26-
func NewUserApiController(s UserApiServicer) UserApiRouter {
26+
func NewUserApiController(s UserApiServicer) Router {
2727
return &UserApiController{ service: s }
2828
}
2929

0 commit comments

Comments
 (0)