// New creates a new default runtime for a swagger api runtime.Client func New(host, basePath string, schemes []string) *Runtime { var rt Runtime rt.DefaultMediaType = runtime.JSONMime // TODO: actually infer this stuff from the spec rt.Consumers = map[string]runtime.Consumer{ runtime.JSONMime: runtime.JSONConsumer(), runtime.XMLMime: runtime.XMLConsumer(), runtime.TextMime: runtime.TextConsumer(), } rt.Producers = map[string]runtime.Producer{ runtime.JSONMime: runtime.JSONProducer(), runtime.XMLMime: runtime.XMLProducer(), runtime.TextMime: runtime.TextProducer(), } rt.Transport = http.DefaultTransport rt.Jar = nil rt.Host = host rt.BasePath = basePath rt.Context = context.Background() rt.clientOnce = new(sync.Once) if !strings.HasPrefix(rt.BasePath, "/") { rt.BasePath = "/" + rt.BasePath } rt.Debug = os.Getenv("DEBUG") == "1" if len(schemes) > 0 { rt.schemes = schemes } return &rt }
func configureAPI(api *operations.PetstoreAPI) http.Handler { // configure the api here api.ServeError = errors.ServeError api.XMLConsumer = runtime.XMLConsumer() api.UrlformConsumer = runtime.DiscardConsumer api.JSONConsumer = runtime.JSONConsumer() api.XMLProducer = runtime.XMLProducer() api.JSONProducer = runtime.JSONProducer() api.APIKeyAuth = func(token string) (interface{}, error) { return nil, errors.NotImplemented("api key auth (api_key) api_key from header has not yet been implemented") } api.PetstoreAuthAuth = func(token string, scopes []string) (interface{}, error) { return nil, errors.NotImplemented("oauth2 bearer auth (petstore_auth) has not yet been implemented") } api.PetAddPetHandler = pet.AddPetHandlerFunc(func(params pet.AddPetParams, principal interface{}) middleware.Responder { return middleware.NotImplemented("operation pet.AddPet has not yet been implemented") }) api.UserCreateUserHandler = user.CreateUserHandlerFunc(func(params user.CreateUserParams) middleware.Responder { return middleware.NotImplemented("operation user.CreateUser has not yet been implemented") }) api.UserCreateUsersWithArrayInputHandler = user.CreateUsersWithArrayInputHandlerFunc(func(params user.CreateUsersWithArrayInputParams) middleware.Responder { return middleware.NotImplemented("operation user.CreateUsersWithArrayInput has not yet been implemented") }) api.UserCreateUsersWithListInputHandler = user.CreateUsersWithListInputHandlerFunc(func(params user.CreateUsersWithListInputParams) middleware.Responder { return middleware.NotImplemented("operation user.CreateUsersWithListInput has not yet been implemented") }) api.StoreDeleteOrderHandler = store.DeleteOrderHandlerFunc(func(params store.DeleteOrderParams) middleware.Responder { return middleware.NotImplemented("operation store.DeleteOrder has not yet been implemented") }) api.PetDeletePetHandler = pet.DeletePetHandlerFunc(func(params pet.DeletePetParams, principal interface{}) middleware.Responder { return middleware.NotImplemented("operation pet.DeletePet has not yet been implemented") }) api.UserDeleteUserHandler = user.DeleteUserHandlerFunc(func(params user.DeleteUserParams) middleware.Responder { return middleware.NotImplemented("operation user.DeleteUser has not yet been implemented") }) api.PetFindPetsByStatusHandler = pet.FindPetsByStatusHandlerFunc(func(params pet.FindPetsByStatusParams, principal interface{}) middleware.Responder { return middleware.NotImplemented("operation pet.FindPetsByStatus has not yet been implemented") }) api.PetFindPetsByTagsHandler = pet.FindPetsByTagsHandlerFunc(func(params pet.FindPetsByTagsParams, principal interface{}) middleware.Responder { return middleware.NotImplemented("operation pet.FindPetsByTags has not yet been implemented") }) api.StoreGetOrderByIDHandler = store.GetOrderByIDHandlerFunc(func(params store.GetOrderByIDParams) middleware.Responder { return middleware.NotImplemented("operation store.GetOrderByID has not yet been implemented") }) api.PetGetPetByIDHandler = pet.GetPetByIDHandlerFunc(func(params pet.GetPetByIDParams, principal interface{}) middleware.Responder { return middleware.NotImplemented("operation pet.GetPetByID has not yet been implemented") }) api.UserGetUserByNameHandler = user.GetUserByNameHandlerFunc(func(params user.GetUserByNameParams) middleware.Responder { return middleware.NotImplemented("operation user.GetUserByName has not yet been implemented") }) api.UserLoginUserHandler = user.LoginUserHandlerFunc(func(params user.LoginUserParams) middleware.Responder { return middleware.NotImplemented("operation user.LoginUser has not yet been implemented") }) api.UserLogoutUserHandler = user.LogoutUserHandlerFunc(func() middleware.Responder { return middleware.NotImplemented("operation user.LogoutUser has not yet been implemented") }) api.StorePlaceOrderHandler = store.PlaceOrderHandlerFunc(func(params store.PlaceOrderParams) middleware.Responder { return middleware.NotImplemented("operation store.PlaceOrder has not yet been implemented") }) api.PetUpdatePetHandler = pet.UpdatePetHandlerFunc(func(params pet.UpdatePetParams, principal interface{}) middleware.Responder { return middleware.NotImplemented("operation pet.UpdatePet has not yet been implemented") }) api.PetUpdatePetWithFormHandler = pet.UpdatePetWithFormHandlerFunc(func(params pet.UpdatePetWithFormParams, principal interface{}) middleware.Responder { return middleware.NotImplemented("operation pet.UpdatePetWithForm has not yet been implemented") }) api.UserUpdateUserHandler = user.UpdateUserHandlerFunc(func(params user.UpdateUserParams) middleware.Responder { return middleware.NotImplemented("operation user.UpdateUser has not yet been implemented") }) api.ServerShutdown = func() {} return setupGlobalMiddleware(api.Serve(setupMiddlewares)) }