Documentation ¶
Index ¶
- Variables
- func AssertCooldownResponseRequired(obj CooldownResponse) error
- func AssertRecurseCooldownResponseRequired(objSlice interface{}) error
- func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error
- func AssertRecurseSuccessfulResponseRequired(objSlice interface{}) error
- func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error
- func AssertSuccessfulResponseRequired(obj SuccessfulResponse) error
- func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)
- func EncodeJSONResponse(i interface{}, status *int, headers map[string][]string, w http.ResponseWriter) error
- func IsZeroValue(val interface{}) bool
- func Logger(inner http.Handler, name string) http.Handler
- func NewRouter(routers ...Router) *mux.Router
- func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)
- func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)
- type CachingApiController
- type CachingApiOption
- type CachingApiRouter
- type CachingApiService
- type CachingApiServicer
- type CooldownResponse
- type ErrorHandler
- type ErrorsApiController
- type ErrorsApiOption
- type ErrorsApiRouter
- type ErrorsApiService
- type ErrorsApiServicer
- type ImplResponse
- type ParsingError
- type RateLimitingApiController
- func (c *RateLimitingApiController) RateLimitByAccountGet(w http.ResponseWriter, r *http.Request)
- func (c *RateLimitingApiController) RateLimitByIpGet(w http.ResponseWriter, r *http.Request)
- func (c *RateLimitingApiController) RateLimitExponentialBackoffGet(w http.ResponseWriter, r *http.Request)
- func (c *RateLimitingApiController) Routes() Routes
- type RateLimitingApiOption
- type RateLimitingApiRouter
- type RateLimitingApiService
- func (s *RateLimitingApiService) RateLimitByAccountGet(ctx context.Context, accountId string) (ImplResponse, error)
- func (s *RateLimitingApiService) RateLimitByIpGet(ctx context.Context) (ImplResponse, error)
- func (s *RateLimitingApiService) RateLimitExponentialBackoffGet(ctx context.Context) (ImplResponse, error)
- type RateLimitingApiServicer
- type RequiredError
- type Route
- type Router
- type Routes
- type SuccessfulResponse
Constants ¶
This section is empty.
Variables ¶
var ErrTypeAssertionError = errors.New("unable to assert type")
ErrTypeAssertionError is thrown when type an interface does not match the asserted type
Functions ¶
func AssertCooldownResponseRequired ¶
func AssertCooldownResponseRequired(obj CooldownResponse) error
AssertCooldownResponseRequired checks if the required fields are not zero-ed
func AssertRecurseCooldownResponseRequired ¶
func AssertRecurseCooldownResponseRequired(objSlice interface{}) error
AssertRecurseCooldownResponseRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of CooldownResponse (e.g. [][]CooldownResponse), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseInterfaceRequired ¶
AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback. This method traverse nested slices in a preorder fashion.
func AssertRecurseSuccessfulResponseRequired ¶
func AssertRecurseSuccessfulResponseRequired(objSlice interface{}) error
AssertRecurseSuccessfulResponseRequired recursively checks if required fields are not zero-ed in a nested slice. Accepts only nested slice of SuccessfulResponse (e.g. [][]SuccessfulResponse), otherwise ErrTypeAssertionError is thrown.
func AssertRecurseValueRequired ¶
AssertRecurseValueRequired checks each struct in the nested slice against the callback. This method traverse nested slices in a preorder fashion.
func AssertSuccessfulResponseRequired ¶
func AssertSuccessfulResponseRequired(obj SuccessfulResponse) error
AssertSuccessfulResponseRequired checks if the required fields are not zero-ed
func DefaultErrorHandler ¶
func DefaultErrorHandler(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)
DefaultErrorHandler defines the default logic on how to handle errors from the controller. Any errors from parsing request params will return a StatusBadRequest. Otherwise, the error code originating from the servicer will be used.
func EncodeJSONResponse ¶
func EncodeJSONResponse(i interface{}, status *int, headers map[string][]string, w http.ResponseWriter) error
EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
func IsZeroValue ¶
func IsZeroValue(val interface{}) bool
IsZeroValue checks if the val is the zero-ed value.
func ReadFormFileToTempFile ¶
ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file
Types ¶
type CachingApiController ¶
type CachingApiController struct {
// contains filtered or unexported fields
}
CachingApiController binds http requests to an api service and writes the service results to the http response
func (*CachingApiController) CacheableGet ¶
func (c *CachingApiController) CacheableGet(w http.ResponseWriter, r *http.Request)
CacheableGet - Get a cacheable response.
func (*CachingApiController) Routes ¶
func (c *CachingApiController) Routes() Routes
Routes returns all the api routes for the CachingApiController
type CachingApiOption ¶
type CachingApiOption func(*CachingApiController)
CachingApiOption for how the controller is set up.
func WithCachingApiErrorHandler ¶
func WithCachingApiErrorHandler(h ErrorHandler) CachingApiOption
WithCachingApiErrorHandler inject ErrorHandler into controller
type CachingApiRouter ¶
type CachingApiRouter interface {
CacheableGet(http.ResponseWriter, *http.Request)
}
CachingApiRouter defines the required methods for binding the api requests to a responses for the CachingApi The CachingApiRouter implementation should parse necessary information from the http request, pass the data to a CachingApiServicer to perform the required actions, then write the service results to the http response.
type CachingApiService ¶
type CachingApiService struct {
// contains filtered or unexported fields
}
CachingApiService is a service that implements the logic for the CachingApiServicer This service should implement the business logic for every endpoint for the CachingApi API. Include any external packages or services that will be required by this service.
func (*CachingApiService) CacheableGet ¶
func (s *CachingApiService) CacheableGet( ctx context.Context, bookTitle string, lineNumber int32, withControl bool, ) (ImplResponse, error)
CacheableGet - Get a cacheable response.
type CachingApiServicer ¶
type CachingApiServicer interface {
CacheableGet(context.Context, string, int32, bool) (ImplResponse, error)
}
CachingApiServicer defines the api actions for the CachingApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can be ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
func NewCachingApiService ¶
func NewCachingApiService(logger zerolog.Logger) CachingApiServicer
NewCachingApiService creates a default api service
type CooldownResponse ¶
type CooldownResponse struct { // Cooldown in seconds Cooldown int32 `json:"cooldown,omitempty"` }
type ErrorHandler ¶
type ErrorHandler func(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)
ErrorHandler defines the required method for handling error. You may implement it and inject this into a controller if you would like errors to be handled differently from the DefaultErrorHandler
type ErrorsApiController ¶
type ErrorsApiController struct {
// contains filtered or unexported fields
}
ErrorsApiController binds http requests to an api service and writes the service results to the http response
func (*ErrorsApiController) ErrorsPercentGet ¶
func (c *ErrorsApiController) ErrorsPercentGet(w http.ResponseWriter, r *http.Request)
ErrorsPercentGet - An API that will return an error \"error_percent\" percent of the time
func (*ErrorsApiController) Routes ¶
func (c *ErrorsApiController) Routes() Routes
Routes returns all the api routes for the ErrorsApiController
type ErrorsApiOption ¶
type ErrorsApiOption func(*ErrorsApiController)
ErrorsApiOption for how the controller is set up.
func WithErrorsApiErrorHandler ¶
func WithErrorsApiErrorHandler(h ErrorHandler) ErrorsApiOption
WithErrorsApiErrorHandler inject ErrorHandler into controller
type ErrorsApiRouter ¶
type ErrorsApiRouter interface {
ErrorsPercentGet(http.ResponseWriter, *http.Request)
}
ErrorsApiRouter defines the required methods for binding the api requests to a responses for the ErrorsApi The ErrorsApiRouter implementation should parse necessary information from the http request, pass the data to a ErrorsApiServicer to perform the required actions, then write the service results to the http response.
type ErrorsApiService ¶
type ErrorsApiService struct{}
ErrorsApiService is a service that implements the logic for the ErrorsApiServicer This service should implement the business logic for every endpoint for the ErrorsApi API. Include any external packages or services that will be required by this service.
func (*ErrorsApiService) ErrorsPercentGet ¶
func (s *ErrorsApiService) ErrorsPercentGet(ctx context.Context, errorPercent int32) (ImplResponse, error)
ErrorsPercentGet - An API that will return an error \"error_percent\" percent of the time
type ErrorsApiServicer ¶
type ErrorsApiServicer interface {
ErrorsPercentGet(context.Context, int32) (ImplResponse, error)
}
ErrorsApiServicer defines the api actions for the ErrorsApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can be ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
func NewErrorsApiService ¶
func NewErrorsApiService() ErrorsApiServicer
NewErrorsApiService creates a default api service
type ImplResponse ¶
ImplResponse response defines an error code with the associated body
func Response ¶
func Response(code int, body interface{}) ImplResponse
Response return a ImplResponse struct filled
func ResponseWithHeaders ¶
func ResponseWithHeaders(code int, headers map[string][]string, body interface{}) ImplResponse
ResponseWithHeaders return a ImplResponse struct filled, including headers
type ParsingError ¶
type ParsingError struct {
Err error
}
ParsingError indicates that an error has occurred when parsing request parameters
func (*ParsingError) Error ¶
func (e *ParsingError) Error() string
func (*ParsingError) Unwrap ¶
func (e *ParsingError) Unwrap() error
type RateLimitingApiController ¶
type RateLimitingApiController struct {
// contains filtered or unexported fields
}
RateLimitingApiController binds http requests to an api service and writes the service results to the http response
func (*RateLimitingApiController) RateLimitByAccountGet ¶
func (c *RateLimitingApiController) RateLimitByAccountGet(w http.ResponseWriter, r *http.Request)
RateLimitByAccountGet - An API with an aggressive rate limit by account
func (*RateLimitingApiController) RateLimitByIpGet ¶
func (c *RateLimitingApiController) RateLimitByIpGet(w http.ResponseWriter, r *http.Request)
RateLimitByIpGet - An API with an aggressive rate limit by IP
func (*RateLimitingApiController) RateLimitExponentialBackoffGet ¶
func (c *RateLimitingApiController) RateLimitExponentialBackoffGet(w http.ResponseWriter, r *http.Request)
RateLimitExponentialBackoffGet - An API with an aggressive rate limit with exponential backoff.
func (*RateLimitingApiController) Routes ¶
func (c *RateLimitingApiController) Routes() Routes
Routes returns all the api routes for the RateLimitingApiController
type RateLimitingApiOption ¶
type RateLimitingApiOption func(*RateLimitingApiController)
RateLimitingApiOption for how the controller is set up.
func WithRateLimitingApiErrorHandler ¶
func WithRateLimitingApiErrorHandler(h ErrorHandler) RateLimitingApiOption
WithRateLimitingApiErrorHandler inject ErrorHandler into controller
type RateLimitingApiRouter ¶
type RateLimitingApiRouter interface { RateLimitByAccountGet(http.ResponseWriter, *http.Request) RateLimitByIpGet(http.ResponseWriter, *http.Request) RateLimitExponentialBackoffGet(http.ResponseWriter, *http.Request) }
RateLimitingApiRouter defines the required methods for binding the api requests to a responses for the RateLimitingApi The RateLimitingApiRouter implementation should parse necessary information from the http request, pass the data to a RateLimitingApiServicer to perform the required actions, then write the service results to the http response.
type RateLimitingApiService ¶
type RateLimitingApiService struct {
// contains filtered or unexported fields
}
RateLimitingApiService is a service that implements the logic for the RateLimitingApiServicer This service should implement the business logic for every endpoint for the RateLimitingApi API. Include any external packages or services that will be required by this service.
func (*RateLimitingApiService) RateLimitByAccountGet ¶
func (s *RateLimitingApiService) RateLimitByAccountGet(ctx context.Context, accountId string) (ImplResponse, error)
RateLimitByAccountGet - An API with an aggressive rate limit by account
func (*RateLimitingApiService) RateLimitByIpGet ¶
func (s *RateLimitingApiService) RateLimitByIpGet(ctx context.Context) (ImplResponse, error)
RateLimitByIpGet - An API with an aggressive rate limit by IP
func (*RateLimitingApiService) RateLimitExponentialBackoffGet ¶
func (s *RateLimitingApiService) RateLimitExponentialBackoffGet(ctx context.Context) (ImplResponse, error)
RateLimitExponentialBackoffGet - An API with an aggressive rate limit with exponential backoff.
type RateLimitingApiServicer ¶
type RateLimitingApiServicer interface { RateLimitByAccountGet(context.Context, string) (ImplResponse, error) RateLimitByIpGet(context.Context) (ImplResponse, error) RateLimitExponentialBackoffGet(context.Context) (ImplResponse, error) }
RateLimitingApiServicer defines the api actions for the RateLimitingApi service This interface intended to stay up to date with the openapi yaml used to generate it, while the service implementation can be ignored with the .openapi-generator-ignore file and updated with the logic required for the API.
func NewRateLimitingApiService ¶
func NewRateLimitingApiService(logger zerolog.Logger) RateLimitingApiServicer
NewRateLimitingApiService creates a default api service
type RequiredError ¶
type RequiredError struct {
Field string
}
RequiredError indicates that an error has occurred when parsing request parameters
func (*RequiredError) Error ¶
func (e *RequiredError) Error() string
type Route ¶
type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc }
A Route defines the parameters for an api endpoint
type Router ¶
type Router interface {
Routes() Routes
}
Router defines the required methods for retrieving api routes
func NewCachingApiController ¶
func NewCachingApiController(s CachingApiServicer, opts ...CachingApiOption) Router
NewCachingApiController creates a default api controller
func NewErrorsApiController ¶
func NewErrorsApiController(s ErrorsApiServicer, opts ...ErrorsApiOption) Router
NewErrorsApiController creates a default api controller
func NewRateLimitingApiController ¶
func NewRateLimitingApiController(s RateLimitingApiServicer, opts ...RateLimitingApiOption) Router
NewRateLimitingApiController creates a default api controller