var ( // ErrTypeAssertionError is thrown when type an interface does not match the asserted type ErrTypeAssertionError = errors.New("unable to assert type") )
func AssertRecurseInterfaceRequired(obj interface{}, callback func(interface{}) error) error
AssertRecurseInterfaceRequired recursively checks each struct in a slice against the callback. This method traverse nested slices in a preorder fashion.
func AssertRecurseValueRequired(value reflect.Value, callback func(interface{}) error) error
AssertRecurseValueRequired checks each struct in the nested slice against the callback. This method traverse nested slices in a preorder fashion.
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 EncodeFileResponse(data io.Reader, filename string, status *int, w http.ResponseWriter) error
EncodeFileResponse writes a binary file to the response
func EncodeJSONResponse(i interface{}, status *int, w http.ResponseWriter) error
EncodeJSONResponse uses the json encoder to write an interface to the http response with an optional status code
func IsZeroValue(val interface{}) bool
IsZeroValue checks if the val is the zero-ed value.
func Logger(inner http.Handler, name string) http.Handler
func NewRouter(routers ...Router) *mux.Router
NewRouter creates a new router for any number of api routers
func ReadFormFileToTempFile(r *http.Request, key string) (*os.File, error)
ReadFormFileToTempFile reads file data from a request form and writes it to a temporary file
func ReadFormFilesToTempFiles(r *http.Request, key string) ([]*os.File, error)
ReadFormFilesToTempFiles reads files array data from a request form and writes it to a temporary files
DefaultApiController binds http requests to an api service and writes the service results to the http response
type DefaultApiController struct {
// contains filtered or unexported fields
}
func (c *DefaultApiController) ReplayIdGet(w http.ResponseWriter, r *http.Request)
ReplayIdGet - Get a replay
func (c *DefaultApiController) Routes() Routes
Routes returns all the api routes for the DefaultApiController
func (c *DefaultApiController) StaffGet(w http.ResponseWriter, r *http.Request)
StaffGet - Get a replay as staff
DefaultApiOption for how the controller is set up.
type DefaultApiOption func(*DefaultApiController)
func WithDefaultApiErrorHandler(h ErrorHandler) DefaultApiOption
WithDefaultApiErrorHandler inject ErrorHandler into controller
DefaultApiRouter defines the required methods for binding the api requests to a responses for the DefaultApi The DefaultApiRouter implementation should parse necessary information from the http request, pass the data to a DefaultApiServicer to perform the required actions, then write the service results to the http response.
type DefaultApiRouter interface { ReplayIdGet(http.ResponseWriter, *http.Request) StaffGet(http.ResponseWriter, *http.Request) }
DefaultApiService is a service that implements the logic for the DefaultApiServicer This service should implement the business logic for every endpoint for the DefaultApi API. Include any external packages or services that will be required by this service.
type DefaultApiService struct { }
func (s *DefaultApiService) ReplayIdGet(ctx context.Context, id string) (ImplResponse, error)
ReplayIdGet - Get a replay
func (s *DefaultApiService) StaffGet(ctx context.Context, ids []string) (ImplResponse, error)
StaffGet - Get a replay as staff
DefaultApiServicer defines the api actions for the DefaultApi 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.
type DefaultApiServicer interface { ReplayIdGet(context.Context, string) (ImplResponse, error) StaffGet(context.Context, []string) (ImplResponse, error) }
func NewDefaultApiService() DefaultApiServicer
NewDefaultApiService creates a default api service
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 ErrorHandler func(w http.ResponseWriter, r *http.Request, err error, result *ImplResponse)
ImplResponse response defines an error code with the associated body
type ImplResponse struct { Code int Body io.Reader Filename string }
func Response(code int, body io.Reader, filename string) ImplResponse
Response return a ImplResponse struct filled
ParsingError indicates that an error has occurred when parsing request parameters
type ParsingError struct { Err error }
func (e *ParsingError) Error() string
func (e *ParsingError) Unwrap() error
RequiredError indicates that an error has occurred when parsing request parameters
type RequiredError struct { Field string }
func (e *RequiredError) Error() string
A Route defines the parameters for an api endpoint
type Route struct { Name string Method string Pattern string HandlerFunc http.HandlerFunc }
Router defines the required methods for retrieving api routes
type Router interface { Routes() Routes }
func NewDefaultApiController(s DefaultApiServicer, opts ...DefaultApiOption) Router
NewDefaultApiController creates a default api controller
Routes are a collection of defined api endpoints
type Routes []Route