Documentation ¶
Overview ¶
Package handlers contains custom handler functions
Index ¶
- Variables
- type CheckFunc
- type Checks
- type Handler
- func (h *Handler) AddReadinessCheck(name string, f CheckFunc)
- func (h *Handler) AddRequestBody(name string, body interface{}, op *openapi3.Operation)
- func (h *Handler) AddResponse(name string, description string, body interface{}, op *openapi3.Operation, ...)
- func (h *Handler) BadRequest(ctx echo.Context, err error) error
- func (h *Handler) BadRequestWithCode(ctx echo.Context, err error, code rout.ErrorCode) error
- func (h *Handler) BindOrganizationHandler() *openapi3.Operation
- func (h *Handler) Conflict(ctx echo.Context, err string, code rout.ErrorCode) error
- func (h *Handler) Created(ctx echo.Context, rep interface{}) error
- func (h *Handler) InternalServerError(ctx echo.Context, err error) error
- func (h *Handler) InvalidInput(ctx echo.Context, err error) error
- func (h *Handler) NotFound(ctx echo.Context, err error) error
- func (h *Handler) OrganizationHandler(ctx echo.Context) error
- func (h *Handler) Success(ctx echo.Context, rep interface{}) error
- func (h *Handler) TooManyRequests(ctx echo.Context, err error) error
- func (h *Handler) Unauthorized(ctx echo.Context, err error) error
- type StatusReply
Constants ¶
This section is empty.
Variables ¶
var ( // ErrInvalidInput is returned when the input is invalid ErrInvalidInput = errors.New("invalid input") // ErrConflict is returned when the request cannot be processed due to a conflict ErrConflict = errors.New("conflict") )
var ( // InvalidInputErrCode is returned when the input is invalid InvalidInputErrCode rout.ErrorCode = "INVALID_INPUT" )
Functions ¶
This section is empty.
Types ¶
type Handler ¶
type Handler struct { // IsTest is a flag to determine if the application is running in test mode and will mock external calls IsTest bool // Logger provides the zap logger to do logging things from the handlers Logger *zap.SugaredLogger // ReadyChecks is a set of checkFuncs to determine if the application is "ready" upon startup ReadyChecks Checks // OpenlaneClient is the client to interact with the openlane API OpenlaneClient *openlaneclient.OpenlaneClient }
Handler contains configuration options for handlers
func (*Handler) AddReadinessCheck ¶
AddReadinessCheck will accept a function to be ran during calls to /readyz These functions should accept a context and only return an error. When adding a readiness check a name is also provided, this name will be used when returning the state of all the checks
func (*Handler) AddRequestBody ¶
AddRequestBody is used to add a request body definition to the OpenAPI schema
func (*Handler) AddResponse ¶
func (h *Handler) AddResponse(name string, description string, body interface{}, op *openapi3.Operation, status int)
AddResponse is used to add a response definition to the OpenAPI schema
func (*Handler) BadRequest ¶
BadRequest returns a 400 Bad Request response with the error message.
func (*Handler) BadRequestWithCode ¶
BadRequest returns a 400 Bad Request response with the error message.
func (*Handler) BindOrganizationHandler ¶
BindOrganizationHandler is used to bind the organization endpoint to the OpenAPI schema
func (*Handler) InternalServerError ¶
InternalServerError returns a 500 Internal Server Error response with the error message.
func (*Handler) InvalidInput ¶
InvalidInput returns a 400 Bad Request response with the error message.
func (*Handler) OrganizationHandler ¶
OrganizationHandler is the handler for the organization endpoint
func (*Handler) TooManyRequests ¶
TooManyRequests returns a 429 Too Many Requests response with the error message.
type StatusReply ¶
StatusReply returns server status