Documentation ¶
Index ¶
- type OpenMockAPI
- func (o *OpenMockAPI) AddMiddlewareFor(method, path string, builder middleware.Builder)
- func (o *OpenMockAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator
- func (o *OpenMockAPI) Authorizer() runtime.Authorizer
- func (o *OpenMockAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer
- func (o *OpenMockAPI) Context() *middleware.Context
- func (o *OpenMockAPI) DefaultConsumes() string
- func (o *OpenMockAPI) DefaultProduces() string
- func (o *OpenMockAPI) Formats() strfmt.Registry
- func (o *OpenMockAPI) HandlerFor(method, path string) (http.Handler, bool)
- func (o *OpenMockAPI) Init()
- func (o *OpenMockAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer
- func (o *OpenMockAPI) RegisterConsumer(mediaType string, consumer runtime.Consumer)
- func (o *OpenMockAPI) RegisterFormat(name string, format strfmt.Format, validator strfmt.Validator)
- func (o *OpenMockAPI) RegisterProducer(mediaType string, producer runtime.Producer)
- func (o *OpenMockAPI) Serve(builder middleware.Builder) http.Handler
- func (o *OpenMockAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error)
- func (o *OpenMockAPI) SetDefaultConsumes(mediaType string)
- func (o *OpenMockAPI) SetDefaultProduces(mediaType string)
- func (o *OpenMockAPI) SetSpec(spec *loads.Document)
- func (o *OpenMockAPI) Validate() error
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type OpenMockAPI ¶
type OpenMockAPI struct { Middleware func(middleware.Builder) http.Handler // BasicAuthenticator generates a runtime.Authenticator from the supplied basic auth function. // It has a default implementation in the security package, however you can replace it for your particular usage. BasicAuthenticator func(security.UserPassAuthentication) runtime.Authenticator // APIKeyAuthenticator generates a runtime.Authenticator from the supplied token auth function. // It has a default implementation in the security package, however you can replace it for your particular usage. APIKeyAuthenticator func(string, string, security.TokenAuthentication) runtime.Authenticator // BearerAuthenticator generates a runtime.Authenticator from the supplied bearer token auth function. // It has a default implementation in the security package, however you can replace it for your particular usage. BearerAuthenticator func(string, security.ScopedTokenAuthentication) runtime.Authenticator // JSONConsumer registers a consumer for the following mime types: // - application/json JSONConsumer runtime.Consumer // YamlConsumer registers a consumer for the following mime types: // - application/yaml YamlConsumer runtime.Consumer // JSONProducer registers a producer for the following mime types: // - application/json JSONProducer runtime.Producer // YamlProducer registers a producer for the following mime types: // - application/yaml YamlProducer runtime.Producer // TemplateDeleteTemplateHandler sets the operation handler for the delete template operation TemplateDeleteTemplateHandler template.DeleteTemplateHandler // TemplateSetDeleteTemplateSetHandler sets the operation handler for the delete template set operation TemplateSetDeleteTemplateSetHandler template_set.DeleteTemplateSetHandler // TemplateDeleteTemplatesHandler sets the operation handler for the delete templates operation TemplateDeleteTemplatesHandler template.DeleteTemplatesHandler // EvaluateEvaluateHandler sets the operation handler for the evaluate operation EvaluateEvaluateHandler evaluate.EvaluateHandler // HealthGetHealthHandler sets the operation handler for the get health operation HealthGetHealthHandler health.GetHealthHandler // TemplateGetTemplatesHandler sets the operation handler for the get templates operation TemplateGetTemplatesHandler template.GetTemplatesHandler // TemplateSetPostTemplateSetHandler sets the operation handler for the post template set operation TemplateSetPostTemplateSetHandler template_set.PostTemplateSetHandler // TemplatePostTemplatesHandler sets the operation handler for the post templates operation TemplatePostTemplatesHandler template.PostTemplatesHandler // ServeError is called when an error is received, there is a default handler // but you can set your own with this ServeError func(http.ResponseWriter, *http.Request, error) // PreServerShutdown is called before the HTTP(S) server is shutdown // This allows for custom functions to get executed before the HTTP(S) server stops accepting traffic PreServerShutdown func() // ServerShutdown is called when the HTTP(S) server is shut down and done // handling all active connections and does not accept connections any more ServerShutdown func() // Custom command line argument groups with their descriptions CommandLineOptionsGroups []swag.CommandLineOptionsGroup // User defined logger function. Logger func(string, ...interface{}) // contains filtered or unexported fields }
OpenMockAPI OpenMock is a Go service that can mock services in integration tests, staging environment, or anywhere. The goal is to simplify the process of writing mocks in various channels. Currently it supports four channels: HTTP, Kafka,, AMQP (e.g. RabbitMQ), and GRPC The admin API allows you to manipulate the mock behaviour provided by openmock, live. The base path for the admin API is "/api/v1".
func NewOpenMockAPI ¶
func NewOpenMockAPI(spec *loads.Document) *OpenMockAPI
NewOpenMockAPI creates a new OpenMock instance
func (*OpenMockAPI) AddMiddlewareFor ¶
func (o *OpenMockAPI) AddMiddlewareFor(method, path string, builder middleware.Builder)
AddMiddlewareFor adds a http middleware to existing handler
func (*OpenMockAPI) AuthenticatorsFor ¶
func (o *OpenMockAPI) AuthenticatorsFor(schemes map[string]spec.SecurityScheme) map[string]runtime.Authenticator
AuthenticatorsFor gets the authenticators for the specified security schemes
func (*OpenMockAPI) Authorizer ¶
func (o *OpenMockAPI) Authorizer() runtime.Authorizer
Authorizer returns the registered authorizer
func (*OpenMockAPI) ConsumersFor ¶
func (o *OpenMockAPI) ConsumersFor(mediaTypes []string) map[string]runtime.Consumer
ConsumersFor gets the consumers for the specified media types. MIME type parameters are ignored here.
func (*OpenMockAPI) Context ¶
func (o *OpenMockAPI) Context() *middleware.Context
Context returns the middleware context for the open mock API
func (*OpenMockAPI) DefaultConsumes ¶
func (o *OpenMockAPI) DefaultConsumes() string
DefaultConsumes returns the default consumes media type
func (*OpenMockAPI) DefaultProduces ¶
func (o *OpenMockAPI) DefaultProduces() string
DefaultProduces returns the default produces media type
func (*OpenMockAPI) Formats ¶
func (o *OpenMockAPI) Formats() strfmt.Registry
Formats returns the registered string formats
func (*OpenMockAPI) HandlerFor ¶
func (o *OpenMockAPI) HandlerFor(method, path string) (http.Handler, bool)
HandlerFor gets a http.Handler for the provided operation method and path
func (*OpenMockAPI) Init ¶
func (o *OpenMockAPI) Init()
Init allows you to just initialize the handler cache, you can then recompose the middleware as you see fit
func (*OpenMockAPI) ProducersFor ¶
func (o *OpenMockAPI) ProducersFor(mediaTypes []string) map[string]runtime.Producer
ProducersFor gets the producers for the specified media types. MIME type parameters are ignored here.
func (*OpenMockAPI) RegisterConsumer ¶
func (o *OpenMockAPI) RegisterConsumer(mediaType string, consumer runtime.Consumer)
RegisterConsumer allows you to add (or override) a consumer for a media type.
func (*OpenMockAPI) RegisterFormat ¶
RegisterFormat registers a custom format validator
func (*OpenMockAPI) RegisterProducer ¶
func (o *OpenMockAPI) RegisterProducer(mediaType string, producer runtime.Producer)
RegisterProducer allows you to add (or override) a producer for a media type.
func (*OpenMockAPI) Serve ¶
func (o *OpenMockAPI) Serve(builder middleware.Builder) http.Handler
Serve creates a http handler to serve the API over HTTP can be used directly in http.ListenAndServe(":8000", api.Serve(nil))
func (*OpenMockAPI) ServeErrorFor ¶
func (o *OpenMockAPI) ServeErrorFor(operationID string) func(http.ResponseWriter, *http.Request, error)
ServeErrorFor gets a error handler for a given operation id
func (*OpenMockAPI) SetDefaultConsumes ¶
func (o *OpenMockAPI) SetDefaultConsumes(mediaType string)
SetDefaultConsumes returns the default consumes media type
func (*OpenMockAPI) SetDefaultProduces ¶
func (o *OpenMockAPI) SetDefaultProduces(mediaType string)
SetDefaultProduces sets the default produces media type
func (*OpenMockAPI) SetSpec ¶
func (o *OpenMockAPI) SetSpec(spec *loads.Document)
SetSpec sets a spec that will be served for the clients.
func (*OpenMockAPI) Validate ¶
func (o *OpenMockAPI) Validate() error
Validate validates the registrations in the OpenMockAPI