Documentation
¶
Overview ¶
Package api provides primitives to interact with the openapi HTTP API.
Code generated by github.com/deepmap/oapi-codegen/v2 version v2.0.0 DO NOT EDIT.
Index ¶
- Constants
- func RegisterHandlers(router gin.IRouter, si ServerInterface)
- func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions)
- func ValidatePath(path string) error
- type APIResponse
- type CallDef
- type CallOutcome
- type ConfigureAPI
- type ConfigureAPIItem
- type ConfigureApiJSONRequestBody
- type DegradeHealthJSONRequestBody
- type DegradeReadyJSONRequestBody
- type ErrorResponse
- type GinServerOptions
- type Health
- type HomeResponse
- type InvalidParameters
- type LatencyDef
- type MiddlewareFunc
- type Normalizer
- type ParamsAPI
- type Reloader
- type ServerInterface
- type ServerInterfaceWrapper
- func (siw *ServerInterfaceWrapper) ConfigureApi(c *gin.Context)
- func (siw *ServerInterfaceWrapper) DegradeHealth(c *gin.Context)
- func (siw *ServerInterfaceWrapper) DegradeReady(c *gin.Context)
- func (siw *ServerInterfaceWrapper) GetApi(c *gin.Context)
- func (siw *ServerInterfaceWrapper) Health(c *gin.Context)
- func (siw *ServerInterfaceWrapper) Home(c *gin.Context)
- func (siw *ServerInterfaceWrapper) ParamsApi(c *gin.Context)
- func (siw *ServerInterfaceWrapper) Ready(c *gin.Context)
- type StatusDef
Constants ¶
const (
MaxRatio = 100_000
)
Variables ¶
This section is empty.
Functions ¶
func RegisterHandlers ¶
func RegisterHandlers(router gin.IRouter, si ServerInterface)
RegisterHandlers creates http.Handler with routing matching OpenAPI spec.
func RegisterHandlersWithOptions ¶
func RegisterHandlersWithOptions(router gin.IRouter, si ServerInterface, options GinServerOptions)
RegisterHandlersWithOptions creates http.Handler with additional options
func ValidatePath ¶
Types ¶
type APIResponse ¶
type APIResponse struct {
Body string `json:"body"`
Calls []CallOutcome `json:"calls"`
LatencyMillis int `json:"latency_millis" yaml:"latency_millis"`
Status int `json:"status"`
}
APIResponse defines model for APIResponse.
type CallDef ¶
type CallDef struct {
// IgnoreStatus don't consider the status code when using `inherit`
IgnoreStatus bool `json:"ignore_status" yaml:"ignore_status"`
// TrimBody don't include the response body in the response of the parent API
TrimBody bool `json:"trim_body" yaml:"trim_body"`
Url string `json:"url"`
}
CallDef a list of urls that we'd call get on
type CallOutcome ¶
type CallOutcome struct {
Body *string `json:"body,omitempty"`
Status int `json:"status"`
Url string `json:"url"`
}
CallOutcome defines model for CallOutcome.
type ConfigureAPI ¶
type ConfigureAPI struct {
// Body The content to return in the response
Body string `json:"body"`
Call []CallDef `json:"call"`
// Latency Extra latency to pick from a uniform distribution to add to this call
Latency *LatencyDef `json:"latency,omitempty"`
// Statuses The status codes to return, it will return with the probability passed in,
// If the sum of the ratio of the entries doesn't add to 100000 it will complete with the status
// of the children calls or 200 if there were no children calls
Statuses []StatusDef `json:"statuses"`
}
ConfigureAPI defines model for ConfigureAPI.
func (*ConfigureAPI) Normalize ¶
func (a *ConfigureAPI) Normalize()
func (*ConfigureAPI) Validate ¶
func (a *ConfigureAPI) Validate() error
type ConfigureAPIItem ¶
type ConfigureAPIItem struct {
Conf ConfigureAPI `json:"conf"`
Path string `json:"path"`
}
ConfigureAPIItem defines model for ConfigureAPIItem.
func (*ConfigureAPIItem) Normalize ¶
func (a *ConfigureAPIItem) Normalize()
func (*ConfigureAPIItem) Validate ¶
func (a *ConfigureAPIItem) Validate() error
type ConfigureApiJSONRequestBody ¶
type ConfigureApiJSONRequestBody = ConfigureAPI
ConfigureApiJSONRequestBody defines body for ConfigureApi for application/json ContentType.
type DegradeHealthJSONRequestBody ¶
type DegradeHealthJSONRequestBody = Health
DegradeHealthJSONRequestBody defines body for DegradeHealth for application/json ContentType.
type DegradeReadyJSONRequestBody ¶
type DegradeReadyJSONRequestBody = Health
DegradeReadyJSONRequestBody defines body for DegradeReady for application/json ContentType.
type ErrorResponse ¶
type ErrorResponse struct {
Details string `json:"details"`
InvalidParameters *[]InvalidParameters `json:"invalid_parameters,omitempty" yaml:"invalid_parameters"`
Status float32 `json:"status"`
}
ErrorResponse defines model for ErrorResponse.
func BadRequestResponse ¶
func BadRequestResponse(err error) ErrorResponse
type GinServerOptions ¶
type GinServerOptions struct {
BaseURL string
Middlewares []MiddlewareFunc
ErrorHandler func(*gin.Context, error, int)
}
GinServerOptions provides options for the Gin server.
type HomeResponse ¶
type HomeResponse struct {
Commit string `json:"commit"`
Hostname string `json:"hostname"`
Target string `json:"target"`
Version string `json:"version"`
}
HomeResponse defines model for HomeResponse.
type InvalidParameters ¶
InvalidParameters defines model for InvalidParameters.
type LatencyDef ¶
type LatencyDef struct {
MaxMillis int `json:"max_millis" yaml:"max_millis"`
MinMillis int `json:"min_millis" yaml:"min_millis"`
}
LatencyDef Extra latency to pick from a uniform distribution to add to this call
func (*LatencyDef) Validate ¶
func (a *LatencyDef) Validate() error
type MiddlewareFunc ¶
type Normalizer ¶
type Normalizer interface {
Normalize()
}
type ParamsAPI ¶
type ParamsAPI struct {
Apis []ConfigureAPIItem `json:"apis"`
}
ParamsAPI defines model for ParamsAPI.
type ServerInterface ¶
type ServerInterface interface {
// home
// (GET /)
Home(c *gin.Context)
// list all apis registered
// (GET /api/dynamic)
ParamsApi(c *gin.Context)
// hello
// (GET /api/dynamic/{path})
GetApi(c *gin.Context, path string)
// set api params
// (POST /api/dynamic/{path})
ConfigureApi(c *gin.Context, path string)
// healthcheck
// (GET /health)
Health(c *gin.Context)
// change healthcheck response
// (POST /health)
DegradeHealth(c *gin.Context)
// healthcheck
// (GET /ready)
Ready(c *gin.Context)
// change healthcheck response
// (POST /ready)
DegradeReady(c *gin.Context)
}
ServerInterface represents all server handlers.
type ServerInterfaceWrapper ¶
type ServerInterfaceWrapper struct {
Handler ServerInterface
HandlerMiddlewares []MiddlewareFunc
ErrorHandler func(*gin.Context, error, int)
}
ServerInterfaceWrapper converts contexts to parameters.
func (*ServerInterfaceWrapper) ConfigureApi ¶
func (siw *ServerInterfaceWrapper) ConfigureApi(c *gin.Context)
ConfigureApi operation middleware
func (*ServerInterfaceWrapper) DegradeHealth ¶
func (siw *ServerInterfaceWrapper) DegradeHealth(c *gin.Context)
DegradeHealth operation middleware
func (*ServerInterfaceWrapper) DegradeReady ¶
func (siw *ServerInterfaceWrapper) DegradeReady(c *gin.Context)
DegradeReady operation middleware
func (*ServerInterfaceWrapper) GetApi ¶
func (siw *ServerInterfaceWrapper) GetApi(c *gin.Context)
GetApi operation middleware
func (*ServerInterfaceWrapper) Health ¶
func (siw *ServerInterfaceWrapper) Health(c *gin.Context)
Health operation middleware
func (*ServerInterfaceWrapper) Home ¶
func (siw *ServerInterfaceWrapper) Home(c *gin.Context)
Home operation middleware
func (*ServerInterfaceWrapper) ParamsApi ¶
func (siw *ServerInterfaceWrapper) ParamsApi(c *gin.Context)
ParamsApi operation middleware
func (*ServerInterfaceWrapper) Ready ¶
func (siw *ServerInterfaceWrapper) Ready(c *gin.Context)
Ready operation middleware
type StatusDef ¶
type StatusDef struct {
// Code The status code to return. `inherit` is a special key that will return whatever `call` leads to
Code string `json:"code"`
// Ratio The proportion of the requests out of 100k that should return this status
Ratio int `json:"ratio"`
}
StatusDef defines model for StatusDef.