Documentation ¶
Index ¶
- Variables
- func Handler[T Env](routeName string, loadEnv func(ctx *fasthttp.RequestCtx) (T, Response, error), ...) func(ctx *fasthttp.RequestCtx)
- func NoEnvHandler(routeName string, next func(ctx *fasthttp.RequestCtx) (Response, error)) func(ctx *fasthttp.RequestCtx)
- type Env
- type ErrorIdResponse
- type JSONResponse
- type Response
- func Created(data any) Response
- func NewJSONResponse(data any, status int, logData log.Field) Response
- func OK(data any) Response
- func OKBytes(body []byte) Response
- func SerializationError(err error) Response
- func ServerError(err error, fullError bool) Response
- func Validation(validator ValidationProvider) Response
- type StaticResponse
- type ValidationProvider
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ValidationLogData = log.NewField(). Int("_code", utils.RES_VALIDATION). Int("status", 400). Finalize() OKLogData = log.NewField(). Int("status", 200). Finalize() CreatedLogData = log.NewField(). Int("status", 201). Finalize() )
View Source
var (
InvalidJSON = StaticError(400, utils.RES_INVALID_JSON_PAYLOAD, "invalid json payload")
)
Functions ¶
func Handler ¶
func Handler[T Env](routeName string, loadEnv func(ctx *fasthttp.RequestCtx) (T, Response, error), next func(ctx *fasthttp.RequestCtx, env T) (Response, error)) func(ctx *fasthttp.RequestCtx)
func NoEnvHandler ¶
func NoEnvHandler(routeName string, next func(ctx *fasthttp.RequestCtx) (Response, error)) func(ctx *fasthttp.RequestCtx)
Types ¶
type ErrorIdResponse ¶
func NewErrorIdResponse ¶ added in v0.0.7
func (ErrorIdResponse) Write ¶
func (r ErrorIdResponse) Write(conn *fasthttp.RequestCtx, logger log.Logger) log.Logger
type JSONResponse ¶ added in v0.0.7
func (JSONResponse) Write ¶ added in v0.0.7
func (r JSONResponse) Write(conn *fasthttp.RequestCtx, logger log.Logger) log.Logger
type Response ¶
type Response interface { // return logger for chaining Write(conn *fasthttp.RequestCtx, logger log.Logger) log.Logger }
func NewJSONResponse ¶ added in v0.0.7
func SerializationError ¶
func ServerError ¶
func Validation ¶
func Validation(validator ValidationProvider) Response
type StaticResponse ¶
type StaticResponse struct {
// contains filtered or unexported fields
}
We know the status/body/logData upfront (lets us optimize EnhanceLog)
func StaticError ¶
func StaticError(status int, code int, error string) StaticResponse
func StaticNotFound ¶
func StaticNotFound(code int) StaticResponse
func (StaticResponse) Write ¶
func (r StaticResponse) Write(conn *fasthttp.RequestCtx, logger log.Logger) log.Logger
type ValidationProvider ¶ added in v0.0.6
type ValidationProvider interface {
Errors() []any
}
Click to show internal directories.
Click to hide internal directories.