[go-server] Enhance Go API server with interfaces router binding and services (#4038)

* Enhance go api server with interfaces router binding and services

Enhance the default go api server generation to define interfaces for an API's routes and services. Handle an endpoint's http binding in the generated router and the skeleton for the service logic in an API service.

* Include interface documentation in Go Server generation.
This commit is contained in:
Jesse Michael
2019-10-19 08:32:52 -07:00
committed by William Cheng
parent dd64241f8f
commit 0abb910dbc
15 changed files with 1083 additions and 257 deletions

View File

@@ -20,13 +20,22 @@ import (
//
// sw "github.com/myname/myrepo/go"
//
sw "./go"
petstoreserver "./go"
)
func main() {
log.Printf("Server started")
router := sw.NewRouter()
PetApiService := petstoreserver.NewPetApiService()
PetApiController := petstoreserver.NewPetApiController(PetApiService)
StoreApiService := petstoreserver.NewStoreApiService()
StoreApiController := petstoreserver.NewStoreApiController(StoreApiService)
UserApiService := petstoreserver.NewUserApiService()
UserApiController := petstoreserver.NewUserApiController(UserApiService)
router := petstoreserver.NewRouter(PetApiController, StoreApiController, UserApiController)
log.Fatal(http.ListenAndServe(":8080", router))
}