Documentation
¶
Overview ¶
Package web exposes public HTTP helpers for request binding, responses, and structured errors.
Index ¶
- Constants
- func AbortError(c *gin.Context, err *errors.HTTPError)
- func Accepted(c *gin.Context, body any)
- func BadRequest(message string) *errors.HTTPError
- func BindJSON[T any](c *gin.Context) (T, error)
- func BindPath[T any](c *gin.Context) (T, error)
- func BindQuery[T any](c *gin.Context) (T, error)
- func Conflict(message string) *errors.HTTPError
- func Created(c *gin.Context, body any)
- func Fail(c *gin.Context, err *HTTPError)
- func FailBind(c *gin.Context, err error)
- func Forbidden(message string) *errors.HTTPError
- func InternalServerError(message string) *errors.HTTPError
- func Module() jelly.Module
- func NewError(status int, code string, message string) *errors.HTTPError
- func NoContent(c *gin.Context)
- func NotFound(message string) *errors.HTTPError
- func OK(c *gin.Context, body any)
- func RegisterValidation(tag string, fn validator.Func) error
- func SetBindErrorEncoder(encoder BindErrorEncoder)
- func SetErrorRenderer(renderer ErrorRenderer)
- func SetHTTPErrorEncoder(encoder HTTPErrorEncoder)
- func Status(c *gin.Context, code int, body any)
- func Unauthorized(message string) *errors.HTTPError
- type BindError
- type BindErrorEncoder
- type BindErrorKind
- type BindSource
- type ErrorPayload
- type ErrorRenderer
- type FieldViolation
- type HTTPError
- type HTTPErrorEncoder
- type MiddlewareProvider
- type RouteProvider
Constants ¶
View Source
const ( BindSourceJSON = binding.BindSourceJSON BindSourcePath = binding.BindSourcePath BindSourceQuery = binding.BindSourceQuery )
View Source
const ( BindErrorMalformedBody = binding.BindErrorMalformedBody BindErrorValidation = binding.BindErrorValidation BindErrorUnsupportedType = binding.BindErrorUnsupportedType BindErrorInvalidParams = binding.BindErrorInvalidParams )
Variables ¶
This section is empty.
Functions ¶
func AbortError ¶
AbortError aborts the request and writes a structured JSON error response.
func BadRequest ¶
BadRequest creates a 400 HTTP error.
func InternalServerError ¶
InternalServerError creates a 500 HTTP error.
func RegisterValidation ¶
RegisterValidation registers a custom validator tag for Jelly bindings.
func SetBindErrorEncoder ¶
func SetBindErrorEncoder(encoder BindErrorEncoder)
func SetErrorRenderer ¶
func SetErrorRenderer(renderer ErrorRenderer)
func SetHTTPErrorEncoder ¶
func SetHTTPErrorEncoder(encoder HTTPErrorEncoder)
func Unauthorized ¶
Unauthorized creates a 401 HTTP error.
Types ¶
type BindErrorEncoder ¶
type BindErrorEncoder interface {
EncodeBindError(err *BindError) ErrorPayload
}
type BindErrorKind ¶
type BindErrorKind = binding.BindErrorKind
type BindSource ¶
type BindSource = binding.BindSource
type ErrorPayload ¶
type ErrorRenderer ¶
type FieldViolation ¶
type FieldViolation = binding.FieldViolation
type HTTPError ¶
type HTTPError = servererrors.HTTPError
type HTTPErrorEncoder ¶
type HTTPErrorEncoder interface {
EncodeHTTPError(err *HTTPError) ErrorPayload
}
type MiddlewareProvider ¶
type MiddlewareProvider = internalweb.MiddlewareProvider
type RouteProvider ¶
type RouteProvider = internalweb.RouteProvider
Source Files
¶
Click to show internal directories.
Click to hide internal directories.