handlers

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Sep 9, 2024 License: Apache-2.0 Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package handlers contains custom handler functions

Index

Constants

This section is empty.

Variables

View Source
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")
)
View Source
var (
	// InvalidInputErrCode is returned when the input is invalid
	InvalidInputErrCode rout.ErrorCode = "INVALID_INPUT"
)

Functions

This section is empty.

Types

type CheckFunc

type CheckFunc func(ctx context.Context) error

CheckFunc is a function that can be used to check the status of a service

type Checks

type Checks struct {
	// contains filtered or unexported fields
}

func (*Checks) ReadyHandler

func (c *Checks) ReadyHandler(ctx echo.Context) error

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

func (h *Handler) AddReadinessCheck(name string, f CheckFunc)

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

func (h *Handler) AddRequestBody(name string, body interface{}, op *openapi3.Operation)

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

func (h *Handler) BadRequest(ctx echo.Context, err error) error

BadRequest returns a 400 Bad Request response with the error message.

func (*Handler) BadRequestWithCode

func (h *Handler) BadRequestWithCode(ctx echo.Context, err error, code rout.ErrorCode) error

BadRequest returns a 400 Bad Request response with the error message.

func (*Handler) BindOrganizationHandler

func (h *Handler) BindOrganizationHandler() *openapi3.Operation

BindOrganizationHandler is used to bind the organization endpoint to the OpenAPI schema

func (*Handler) Conflict

func (h *Handler) Conflict(ctx echo.Context, err string, code rout.ErrorCode) error

Conflict returns a 409 Conflict response with the error message.

func (*Handler) Created

func (h *Handler) Created(ctx echo.Context, rep interface{}) error

Created returns a 201 Created response with the response object.

func (*Handler) InternalServerError

func (h *Handler) InternalServerError(ctx echo.Context, err error) error

InternalServerError returns a 500 Internal Server Error response with the error message.

func (*Handler) InvalidInput

func (h *Handler) InvalidInput(ctx echo.Context, err error) error

InvalidInput returns a 400 Bad Request response with the error message.

func (*Handler) NotFound

func (h *Handler) NotFound(ctx echo.Context, err error) error

NotFound returns a 404 Not Found response with the error message.

func (*Handler) OrganizationHandler

func (h *Handler) OrganizationHandler(ctx echo.Context) error

OrganizationHandler is the handler for the organization endpoint

func (*Handler) Success

func (h *Handler) Success(ctx echo.Context, rep interface{}) error

Success returns a 200 OK response with the response object.

func (*Handler) TooManyRequests

func (h *Handler) TooManyRequests(ctx echo.Context, err error) error

TooManyRequests returns a 429 Too Many Requests response with the error message.

func (*Handler) Unauthorized

func (h *Handler) Unauthorized(ctx echo.Context, err error) error

Unauthorized returns a 401 Unauthorized response with the error message.

type StatusReply

type StatusReply struct {
	Status map[string]string `json:"status"`
}

StatusReply returns server status

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL