handler

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Dec 21, 2025 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func LogErrorStacktrace

func LogErrorStacktrace(err error)

Types

type App

type App interface {
	HandleRequest(requests requests.Request) (interface{}, error)
}

type BaseHandler

type BaseHandler struct {
	App App
}

BaseHandler is a struct with basic methods that should be extended to properly handle a HTTP Service.

func NewHandler

func NewHandler(App App) *BaseHandler

func (*BaseHandler) BindedJSONResponse

func (h *BaseHandler) BindedJSONResponse(c echo.Context, op string, request requests.Request, body requests.Body) error

func (*BaseHandler) BindedXMLResponse

func (h *BaseHandler) BindedXMLResponse(c echo.Context, op string, request requests.Request, body requests.Body) error

func (*BaseHandler) BlobResponse

func (h *BaseHandler) BlobResponse(c echo.Context, op string, request requests.Request, contentType string, body requests.Body) error

func (*BaseHandler) GetListLimit

func (h *BaseHandler) GetListLimit(c echo.Context, defaultLimit int) int

func (*BaseHandler) GetListOffset

func (h *BaseHandler) GetListOffset(c echo.Context, defaultOffset int) int

func (*BaseHandler) GetNumericQueryParam

func (h *BaseHandler) GetNumericQueryParam(c echo.Context, param string, defaultValue int) int

func (*BaseHandler) GetParameterInt64

func (h *BaseHandler) GetParameterInt64(c echo.Context, name string) (int64, error)

func (*BaseHandler) GetParameterString

func (h *BaseHandler) GetParameterString(c echo.Context, name string) (string, error)

Parameters

func (*BaseHandler) GetParameterUUID

func (h *BaseHandler) GetParameterUUID(c echo.Context, name string) (uuid.UUID, error)

func (*BaseHandler) GetQueryParamInt64

func (h *BaseHandler) GetQueryParamInt64(c echo.Context, value string) (int64, error)

func (*BaseHandler) GetQueryParamInt64s

func (h *BaseHandler) GetQueryParamInt64s(c echo.Context, key string) ([]int64, error)

func (*BaseHandler) GetQueryParamTime added in v1.5.3

func (h *BaseHandler) GetQueryParamTime(c echo.Context, key string) (time.Time, error)

GetQueryParamTime parses a required query param as RFC3339/RFC3339Nano

func (*BaseHandler) JSONResponse

func (h *BaseHandler) JSONResponse(c echo.Context, op string, request requests.Request, body requests.Body) error

func (*BaseHandler) ManageError

func (h *BaseHandler) ManageError(c echo.Context, op string, request requests.Request, err error) error

ManageError translates an error into the appropriate HTTP error code

type ErrorResponse

type ErrorResponse struct {
	Error StandardError `json:"error"`
}

ErrorResponse defines the structure of the error that the handler will return

type StandardError

type StandardError struct {
	Code      string `json:"code"`
	Message   string `json:"message"`
	RequestID string `json:"request_id"`
}

StandardError defines a error in JSON format

Jump to

Keyboard shortcuts

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