Documentation
¶
Index ¶
- Constants
- type Intermediate
- type Mock
- func (svc *Mock) AddPet(ctx context.Context, httpRequestBody *petstoreapi.Pet) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error)
- func (svc *Mock) GetPetById(ctx context.Context, petId int64) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error)
- func (svc *Mock) MockAddPet(...) *Mock
- func (svc *Mock) MockGetPetById(...) *Mock
- func (svc *Mock) MockUploadFile(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
- func (svc *Mock) OnShutdown(ctx context.Context) (err error)
- func (svc *Mock) OnStartup(ctx context.Context) (err error)
- func (svc *Mock) UploadFile(w http.ResponseWriter, r *http.Request) (err error)
- type Service
- func (svc *Service) AddPet(ctx context.Context, httpRequestBody *petstoreapi.Pet) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error)
- func (svc *Service) GetPetById(ctx context.Context, petId int64) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error)
- func (svc *Service) Init(initializer func(svc *Service) (err error)) *Service
- func (svc *Service) OnShutdown(ctx context.Context) (err error)
- func (svc *Service) OnStartup(ctx context.Context) (err error)
- func (svc *Service) UploadFile(w http.ResponseWriter, r *http.Request) (err error)
- type ToDo
Constants ¶
const ( Hostname = petstoreapi.Hostname Version = petstoreapi.Version Description = petstoreapi.Description )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Intermediate ¶
Intermediate extends and customizes the generic base connector.
func NewIntermediate ¶
func NewIntermediate(impl ToDo) *Intermediate
NewIntermediate creates a new instance of the intermediate.
func (*Intermediate) BearerToken ¶
func (svc *Intermediate) BearerToken() (value string)
BearerToken is the OAuth2 bearer token presented to the remote Swagger Petstore API.
func (*Intermediate) RemoteBaseURL ¶
func (svc *Intermediate) RemoteBaseURL() (value string)
RemoteBaseURL is the base URL of the remote Swagger Petstore API.
func (*Intermediate) SetBearerToken ¶
func (svc *Intermediate) SetBearerToken(value string) (err error)
SetBearerToken sets the value of the configuration property.
func (*Intermediate) SetRemoteBaseURL ¶
func (svc *Intermediate) SetRemoteBaseURL(value string) (err error)
SetRemoteBaseURL sets the value of the configuration property.
type Mock ¶
type Mock struct {
*Intermediate
// contains filtered or unexported fields
}
Mock is a mockable version of the microservice, allowing functions, event sinks and web handlers to be mocked.
func (*Mock) AddPet ¶
func (svc *Mock) AddPet(ctx context.Context, httpRequestBody *petstoreapi.Pet) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error)
AddPet executes the mock handler.
func (*Mock) GetPetById ¶
func (svc *Mock) GetPetById(ctx context.Context, petId int64) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error)
GetPetById executes the mock handler.
func (*Mock) MockAddPet ¶
func (svc *Mock) MockAddPet(handler func(ctx context.Context, httpRequestBody *petstoreapi.Pet) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error)) *Mock
MockAddPet sets up a mock handler for AddPet.
func (*Mock) MockGetPetById ¶
func (svc *Mock) MockGetPetById(handler func(ctx context.Context, petId int64) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error)) *Mock
MockGetPetById sets up a mock handler for GetPetById.
func (*Mock) MockUploadFile ¶
func (svc *Mock) MockUploadFile(handler func(w http.ResponseWriter, r *http.Request) (err error)) *Mock
MockUploadFile sets up a mock handler for UploadFile.
func (*Mock) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
func (*Mock) UploadFile ¶
UploadFile executes the mock handler.
type Service ¶
type Service struct {
*Intermediate // IMPORTANT: Do not remove
}
Service implements petstore which delegates to the Swagger Petstore API.
This is a sample Pet Store Server based on the OpenAPI 3.0 specification. You can find out more about Swagger at [https://swagger.io](https://swagger.io). In the third iteration of the pet store, we've switched to the design first approach! You can now help us improve the API whether it's by making changes to the definition itself or to the code. That way, with time, we can improve the API in general, and expose some of the new features in OAS3.
Some useful links: - [The Pet Store repository](https://github.com/swagger-api/swagger-petstore) - [The source API definition for the Pet Store](https://github.com/swagger-api/swagger-petstore/blob/master/src/main/resources/openapi.yaml)
func (*Service) AddPet ¶
func (svc *Service) AddPet(ctx context.Context, httpRequestBody *petstoreapi.Pet) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error)
AddPet adds a new pet to the store.
Input:
- httpRequestBody: httpRequestBody is the pet to add
Output:
- httpResponseBody: httpResponseBody is the created pet
- httpStatusCode: httpStatusCode is the remote HTTP status code
func (*Service) GetPetById ¶
func (svc *Service) GetPetById(ctx context.Context, petId int64) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error)
GetPetById returns a single pet.
Input:
- petId: petId is the ID of the pet to return
Output:
- httpResponseBody: httpResponseBody is the requested pet
- httpStatusCode: httpStatusCode is the remote HTTP status code
func (*Service) OnShutdown ¶
OnShutdown is called when the microservice is shut down.
func (*Service) UploadFile ¶
UploadFile uploads an image of the pet.
type ToDo ¶
type ToDo interface {
OnStartup(ctx context.Context) (err error)
OnShutdown(ctx context.Context) (err error)
AddPet(ctx context.Context, httpRequestBody *petstoreapi.Pet) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error) // MARKER: AddPet
GetPetById(ctx context.Context, petId int64) (httpResponseBody *petstoreapi.Pet, httpStatusCode int, err error) // MARKER: GetPetById
UploadFile(w http.ResponseWriter, r *http.Request) (err error) // MARKER: UploadFile
}
ToDo is implemented by the service or mock. The intermediate delegates handling to this interface.