Documentation ¶
Overview ¶
Package api implements echo http server handlers and boilerplate code
Index ¶
- Constants
- func GetContentSize(ctx echo.Context) int64
- func GetContentType(ctx echo.Context) string
- func GetNamespace(ctx echo.Context) data.Namespace
- func GetRequestContext(ctx echo.Context) context.Context
- func GetRequestID(ctx echo.Context) string
- func HealthzHandler(ctx echo.Context) error
- func ReadyzHandler(fns ...func(ctx context.Context) HealthEntryStatus) func(echo.Context) error
- func ServerHeader(name, version string) echo.MiddlewareFunc
- type ErrorHandler
- type ErrorResponse
- type HealthEntryStatus
- type HealthStatusResponse
- type Status
Constants ¶
const ( // LivenessPath endpoint default path LivenessPath = "/healthz" // ReadinessPath endpoint default path ReadinessPath = "/readyz" // StatusHealthy means that service in health state StatusHealthy = Status("StatusHealthy") // StatusUnhealthy means that service is in degraded state StatusUnhealthy = Status("StatusUnhealthy") )
const (
// DefaultNamespaceValue is default OTA namespace
DefaultNamespaceValue = "default"
)
Variables ¶
This section is empty.
Functions ¶
func GetContentSize ¶
func GetContentSize(ctx echo.Context) int64
GetContentSize returns Content length from request header
func GetContentType ¶
func GetContentType(ctx echo.Context) string
GetContentType returns value of ContentType header
func GetNamespace ¶ added in v1.0.15
GetNamespace returns OTA namespace from header
func GetRequestContext ¶
GetRequestContext return populated request context.Context
func GetRequestID ¶ added in v1.0.17
func GetRequestID(ctx echo.Context) string
GetRequestID returns RequestID from header
func HealthzHandler ¶
func HealthzHandler(ctx echo.Context) error
HealthzHandler is a k8s liveness endpoint
func ReadyzHandler ¶
func ReadyzHandler(fns ...func(ctx context.Context) HealthEntryStatus) func(echo.Context) error
ReadyzHandler is a k8s readiness endpoint
func ServerHeader ¶
func ServerHeader(name, version string) echo.MiddlewareFunc
ServerHeader middleware adds a `Server` header to the response.
Types ¶
type ErrorHandler ¶
type ErrorHandler struct { Handler echo.HTTPErrorHandler // contains filtered or unexported fields }
ErrorHandler is a wrapper on echo.HTTPErrorHandler
func NewErrorHandler ¶
func NewErrorHandler() *ErrorHandler
NewErrorHandler sets up the mapping of error type to handler
type ErrorResponse ¶
type ErrorResponse struct { // ErrorCode application error code ErrorCode string `json:"error_code"` // StatusCode HTTP response status code StatusCode int `json:"status_code"` // Description description of error Description string `json:"description"` // RequestID HTTP requestID go from header of request RequestID string `json:"request_id"` }
ErrorResponse is http error response model
func NewErrorResponse ¶
func NewErrorResponse(ctx context.Context, statusCode int, err error) ErrorResponse
NewErrorResponse creates new error response from error
type HealthEntryStatus ¶
type HealthEntryStatus struct { Status Status `json:"status"` Data interface{} `json:"data"` Resource string `json:"resource"` }
HealthEntryStatus is status of external dependency like db or queue
type HealthStatusResponse ¶
type HealthStatusResponse struct { Status Status `json:"status"` Entries []HealthEntryStatus `json:"entries,omitempty"` }
HealthStatusResponse response of health endpoints