Documentation
¶
Index ¶
- Constants
- Variables
- type CorsOption
- type Interface
- type MiddlewareHandler
- type Option
- func WithCore(core *fasthttp.Server) Option
- func WithCoreOptions(opts ...core.Option) Option
- func WithListener(listener net.Listener) Option
- func WithListenerOptions(opts ...listener.Option) Option
- func WithRouter(router *fasthttpRouter.Router) Option
- func WithRouterOptions(opts ...router.Option) Option
- func WithShutdownTimeout(timeout time.Duration) Option
- func WithTLS(tls *TLS) Option
- func WithTelemetryManager(telemetry telemetry.Interface) Option
- func WithoutShutdownHandler() Option
- type RequestContext
- func (c *RequestContext) GetBearerToken() (string, error)
- func (c *RequestContext) GetContext() context.Context
- func (c *RequestContext) GetHeaderStr(key string) string
- func (c *RequestContext) GetIpAddr() string
- func (c *RequestContext) ReadJsonBody(data any) error
- func (c *RequestContext) SetTraceIdHeader()
- func (c *RequestContext) UserValueBool(key any) (bool, error)
- func (c *RequestContext) UserValueInt(key any) (int, error)
- func (c *RequestContext) UserValueStr(key any) (string, error)
- func (c *RequestContext) UserValueUint(key any) (uint, error)
- func (c *RequestContext) Write(p []byte) (int, error)
- func (c *RequestContext) WriteError(err error)
- func (c *RequestContext) WriteJson(data any) error
- func (c *RequestContext) WriteJsonWithStatusCode(statusCode int, data any) error
- func (c *RequestContext) WriteStatusCode(code int)
- func (c *RequestContext) WriteString(s string) (int, error)
- type RequestHandler
- type RouteGroupOption
- type RouteOption
- func WithRouteBodyParserHandler[T any](handler func(context.Context, *RequestContext, *T)) RouteOption
- func WithRouteHandler(handler func(context.Context, *RequestContext)) RouteOption
- func WithRouteMethod(method string) RouteOption
- func WithRouteMiddlewares(middlewares ...MiddlewareHandler) RouteOption
- func WithRoutePath(path string) RouteOption
- type TLS
Constants ¶
Variables ¶
View Source
var ErrorStatusCodeMap = map[error]int{ errors.ErrBadRequest: fasthttp.StatusBadRequest, errors.ErrUnauthorized: fasthttp.StatusUnauthorized, errors.ErrPaymentRequired: fasthttp.StatusPaymentRequired, errors.ErrForbidden: fasthttp.StatusForbidden, errors.ErrNotFound: fasthttp.StatusNotFound, errors.ErrMethodNotAllowed: fasthttp.StatusMethodNotAllowed, errors.ErrConflict: fasthttp.StatusConflict, errors.ErrGone: fasthttp.StatusGone, errors.ErrRequestEntityTooLarge: fasthttp.StatusRequestEntityTooLarge, errors.ErrUnsupportedMediaType: fasthttp.StatusUnsupportedMediaType, errors.ErrRequestedRangeNotSatisfiable: fasthttp.StatusRequestedRangeNotSatisfiable, errors.ErrTeapot: fasthttp.StatusTeapot, errors.ErrUnprocessableEntity: fasthttp.StatusUnprocessableEntity, errors.ErrLocked: fasthttp.StatusLocked, errors.ErrFailedDependency: fasthttp.StatusFailedDependency, errors.ErrPreconditionRequired: fasthttp.StatusPreconditionRequired, errors.ErrTooManyRequests: fasthttp.StatusTooManyRequests, errors.ErrUnavailableForLegalReasons: fasthttp.StatusUnavailableForLegalReasons, errors.ErrInternalServerError: fasthttp.StatusInternalServerError, errors.ErrNotImplemented: fasthttp.StatusNotImplemented, errors.ErrBadGateway: fasthttp.StatusBadGateway, errors.ErrServiceUnavailable: fasthttp.StatusServiceUnavailable, errors.ErrGatewayTimeout: fasthttp.StatusGatewayTimeout, errors.ErrLoopDetected: fasthttp.StatusLoopDetected, }
Functions ¶
This section is empty.
Types ¶
type CorsOption ¶
type CorsOption func(*cors)
func WithCorsHeaders ¶
func WithCorsHeaders(headers string) CorsOption
func WithCorsMethods ¶
func WithCorsMethods(methods string) CorsOption
func WithCorsOrigin ¶
func WithCorsOrigin(origin string) CorsOption
type Interface ¶
type Interface interface {
SetListener(listener net.Listener) Interface
SetCore(core *fasthttp.Server) Interface
SetRouter(router *fasthttpRouter.Router) Interface
SetTelemetryManager(telemetry telemetry.Interface) Interface
EnableTLS(tls *TLS) Interface
AddMiddleware(MiddlewareHandler) Interface
AddRoute(opts ...RouteOption) Interface
AddRouteGroup(opts ...RouteGroupOption) Interface
UseCors(opts ...CorsOption) Interface
UseSwagger() Interface
UseProfiling() Interface
Listen() <-chan error
Up()
GetShutdownTimeout() time.Duration
GetShutdownHandler() bool
Shutdown(ctx context.Context, reason string) error
ShutdownHandler(sig os.Signal) error
}
type MiddlewareHandler ¶
type MiddlewareHandler func(RequestHandler) RequestHandler
type Option ¶
type Option func(*server)
func WithCoreOptions ¶
func WithListener ¶
func WithListenerOptions ¶
func WithRouter ¶
func WithRouter(router *fasthttpRouter.Router) Option
func WithRouterOptions ¶
func WithShutdownTimeout ¶
func WithTelemetryManager ¶
func WithoutShutdownHandler ¶
func WithoutShutdownHandler() Option
type RequestContext ¶
type RequestContext struct {
*fasthttp.RequestCtx
}
func (*RequestContext) GetBearerToken ¶
func (c *RequestContext) GetBearerToken() (string, error)
func (*RequestContext) GetContext ¶
func (c *RequestContext) GetContext() context.Context
func (*RequestContext) GetHeaderStr ¶
func (c *RequestContext) GetHeaderStr(key string) string
func (*RequestContext) GetIpAddr ¶
func (c *RequestContext) GetIpAddr() string
func (*RequestContext) ReadJsonBody ¶
func (c *RequestContext) ReadJsonBody(data any) error
func (*RequestContext) SetTraceIdHeader ¶
func (c *RequestContext) SetTraceIdHeader()
func (*RequestContext) UserValueBool ¶
func (c *RequestContext) UserValueBool(key any) (bool, error)
func (*RequestContext) UserValueInt ¶
func (c *RequestContext) UserValueInt(key any) (int, error)
func (*RequestContext) UserValueStr ¶
func (c *RequestContext) UserValueStr(key any) (string, error)
func (*RequestContext) UserValueUint ¶
func (c *RequestContext) UserValueUint(key any) (uint, error)
func (*RequestContext) WriteError ¶
func (c *RequestContext) WriteError(err error)
func (*RequestContext) WriteJson ¶
func (c *RequestContext) WriteJson(data any) error
func (*RequestContext) WriteJsonWithStatusCode ¶
func (c *RequestContext) WriteJsonWithStatusCode(statusCode int, data any) error
func (*RequestContext) WriteStatusCode ¶
func (c *RequestContext) WriteStatusCode(code int)
func (*RequestContext) WriteString ¶
func (c *RequestContext) WriteString(s string) (int, error)
type RequestHandler ¶
type RequestHandler func(*RequestContext)
type RouteGroupOption ¶
type RouteGroupOption func(*routeGroup)
func WithRouteGroup ¶
func WithRouteGroup(opts ...RouteGroupOption) RouteGroupOption
func WithRouteGroupMiddlewares ¶
func WithRouteGroupMiddlewares(middlewares ...MiddlewareHandler) RouteGroupOption
func WithRouteGroupPath ¶
func WithRouteGroupPath(path string) RouteGroupOption
func WithRouteGroupRoute ¶
func WithRouteGroupRoute(opts ...RouteOption) RouteGroupOption
type RouteOption ¶
type RouteOption func(*route)
func WithRouteBodyParserHandler ¶
func WithRouteBodyParserHandler[T any](handler func(context.Context, *RequestContext, *T)) RouteOption
func WithRouteHandler ¶
func WithRouteHandler(handler func(context.Context, *RequestContext)) RouteOption
func WithRouteMethod ¶
func WithRouteMethod(method string) RouteOption
func WithRouteMiddlewares ¶
func WithRouteMiddlewares(middlewares ...MiddlewareHandler) RouteOption
func WithRoutePath ¶
func WithRoutePath(path string) RouteOption
Click to show internal directories.
Click to hide internal directories.