Documentation
¶
Index ¶
- Constants
- func SendJSONError(ctx echo.Context, status int, title string, opts ...ErrorOption) error
- type Error
- type ErrorOption
- type Option
- func WitHealthCheckCtx(ctx context.Context) Option
- func WithBodyLimit(limit string) Option
- func WithCORSAllowOrigins(allowedOrigins []string) Option
- func WithLogger(logger *slog.Logger) Option
- func WithRateLimiter(rate int, burst int) Option
- func WithReadTimeout(d time.Duration) Option
- func WithSonicSerializer() Option
- func WithStaticRoot(root string) Option
- func WithSwaggerDarkStyle(enabled bool) Option
- func WithSwaggerRoot(root string) Option
- func WithTracing(enabled bool) Option
- func WithWriteTimeout(d time.Duration) Option
- type PanicError
- type Server
Constants ¶
const MIMEApplicationProblemJSON = "application/problem+json"
Variables ¶
This section is empty.
Functions ¶
func SendJSONError ¶
Types ¶
type Error ¶
type Error struct {
Type string `json:"type"`
Title string `json:"title"`
Status int `json:"status"`
Detail string `json:"detail,omitempty"`
Instance string `json:"instance,omitempty"`
Errors []interface{} `json:"errors,omitempty"`
}
Error is JSON error described by RFC9457. @see https://datatracker.ietf.org/doc/html/rfc9457/ @note subtle deviation from rfc - title and status are required.
type ErrorOption ¶
type ErrorOption func(error *Error)
func WithDetail ¶
func WithDetail(detail string) ErrorOption
func WithInstance ¶
func WithInstance(instance string) ErrorOption
func WithValidationErrors ¶
func WithValidationErrors[T validationErrorAccessor](errs ...T) ErrorOption
WithValidationErrors translates various interfaces to json errors.
type Option ¶
type Option func(s *Server)
func WitHealthCheckCtx ¶
WitHealthCheckCtx sets the health-check context. Once context is canceled, health-check will return error.
func WithBodyLimit ¶
WithBodyLimit sets the maximum allowed size of the request body. Limit can be specified as 4x or 4xB, where x is one of the multiple from K, M, G, T or P.
func WithCORSAllowOrigins ¶
WithCORSAllowOrigins sets the allowed origins for CORS requests.
func WithRateLimiter ¶
WithRateLimiter enables/disables rate limiting.
func WithReadTimeout ¶
WithReadTimeout sets the read timeout.
func WithSonicSerializer ¶
func WithSonicSerializer() Option
WithSonicSerializer uses bytedance/sonic as json serializer
func WithStaticRoot ¶
WithStaticRoot sets the root directory for static files.
func WithSwaggerDarkStyle ¶
WithSwaggerDarkStyle enabled dark theme for swagger UI page
func WithSwaggerRoot ¶
WithSwaggerRoot sets the root for swagger files. @note given directory should contain folders: v1, v2, etc.
func WithWriteTimeout ¶
WithWriteTimeout sets the write timeout.
type PanicError ¶
func (*PanicError) Error ¶
func (e *PanicError) Error() string
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
func (*Server) Register ¶
func (s *Server) Register(adapters ...adapterAccessor)
Register adapters for /
func (*Server) RegisterV1 ¶
func (s *Server) RegisterV1(adapters ...adapterAccessor)
RegisterV1 adapters for /api/v1/
Directories
¶
| Path | Synopsis |
|---|---|
|
Package mocks is a generated GoMock package.
|
Package mocks is a generated GoMock package. |