Documentation
¶
Index ¶
- Variables
- func RespondError(ctx context.Context, w http.ResponseWriter, err error)
- func RespondSuccess(ctx context.Context, w http.ResponseWriter, statusCode int, v any)
- type Error
- type RequestDecoder
- func (d RequestDecoder) Body(v any) error
- func (d RequestDecoder) Header(key string, val any, defaultVal any) error
- func (d RequestDecoder) MergeResults(errs ...error) error
- func (d RequestDecoder) Path(key string, val any, defaultVal any) error
- func (d RequestDecoder) Query(key string, val any, defaultVal any) error
- type Server
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrInternalServer = Error{ Code: "CM0001", Message: "internal server error", StatusCode: http.StatusInternalServerError, } ErrDecodeBodyFailed = Error{ Code: "CM0002", Message: "decode body error", StatusCode: http.StatusBadRequest, } ErrDecodePathParamsFailed = Error{ Code: "CM0003", Message: "decode path params error", StatusCode: http.StatusBadRequest, } ErrDecodeHeaderParamsFailed = Error{ Code: "CM0004", Message: "decode header params error", StatusCode: http.StatusBadRequest, } ErrDecodeQueryParamsFailed = Error{ Code: "CM0005", Message: "decode query params error", StatusCode: http.StatusBadRequest, } ErrValidationFailed = Error{ Code: "CM0006", Message: "validation error", StatusCode: http.StatusBadRequest, } ErrInvalidAuthorization = Error{ Code: "CM0007", Message: "invalid Authorization header or query param", StatusCode: http.StatusBadRequest, } ErrForbiddenPerformAction = Error{ Code: "CM0008", Message: "it's forbidden to perform this action", StatusCode: http.StatusForbidden, } )
Functions ¶
func RespondError ¶
func RespondError(ctx context.Context, w http.ResponseWriter, err error)
func RespondSuccess ¶
Types ¶
type Error ¶
type RequestDecoder ¶
type RequestDecoder struct {
// contains filtered or unexported fields
}
func NewRequestDecoder ¶
func NewRequestDecoder(req *http.Request) RequestDecoder
func (RequestDecoder) Body ¶
func (d RequestDecoder) Body(v any) error
func (RequestDecoder) Header ¶
func (d RequestDecoder) Header(key string, val any, defaultVal any) error
func (RequestDecoder) MergeResults ¶
func (d RequestDecoder) MergeResults(errs ...error) error
Click to show internal directories.
Click to hide internal directories.