Documentation
¶
Index ¶
- Constants
- func Wrap(p Problem) error
- func WrapError(err error) error
- func WriteJson(ctx context.Context, w http.ResponseWriter, status int, v interface{})
- func WriteXml(ctx context.Context, w http.ResponseWriter, status int, v interface{})
- type BadRequest
- type Builder
- func (b *Builder) BadGateway(format string, args ...interface{}) Problem
- func (b *Builder) BadRequest(format string, args ...interface{}) Problem
- func (b *Builder) Conflict(format string, args ...interface{}) Problem
- func (b *Builder) ExpectationFailed(format string, args ...interface{}) Problem
- func (b *Builder) FailedDependency(format string, args ...interface{}) Problem
- func (b *Builder) Forbidden(format string, args ...interface{}) Problem
- func (b *Builder) GatewayTimeout(format string, args ...interface{}) Problem
- func (b *Builder) Gone(format string, args ...interface{}) Problem
- func (b *Builder) HTTPVersionNotSupported(format string, args ...interface{}) Problem
- func (b *Builder) InsufficientStorage(format string, args ...interface{}) Problem
- func (b *Builder) InternalServerError(format string, args ...interface{}) Problem
- func (b *Builder) LengthRequired(format string, args ...interface{}) Problem
- func (b *Builder) Locked(format string, args ...interface{}) Problem
- func (b *Builder) LoopDetected(format string, args ...interface{}) Problem
- func (b *Builder) MethodNotAllowed(format string, args ...interface{}) Problem
- func (b *Builder) MisdirectedRequest(format string, args ...interface{}) Problem
- func (b *Builder) NetworkAuthenticationRequired(format string, args ...interface{}) Problem
- func (b *Builder) NotAcceptable(format string, args ...interface{}) Problem
- func (b *Builder) NotExtended(format string, args ...interface{}) Problem
- func (b *Builder) NotFound(format string, args ...interface{}) Problem
- func (b *Builder) NotImplemented(format string, args ...interface{}) Problem
- func (b *Builder) PaymentRequired(format string, args ...interface{}) Problem
- func (b *Builder) PreconditionFailed(format string, args ...interface{}) Problem
- func (b *Builder) PreconditionRequired(format string, args ...interface{}) Problem
- func (b *Builder) ProxyAuthRequired(format string, args ...interface{}) Problem
- func (b *Builder) RequestEntityTooLarge(format string, args ...interface{}) Problem
- func (b *Builder) RequestHeaderFieldsTooLarge(format string, args ...interface{}) Problem
- func (b *Builder) RequestTimeout(format string, args ...interface{}) Problem
- func (b *Builder) RequestURITooLong(format string, args ...interface{}) Problem
- func (b *Builder) RequestedRangeNotSatisfiable(format string, args ...interface{}) Problem
- func (b *Builder) Teapot(format string, args ...interface{}) Problem
- func (b *Builder) TooEarly(format string, args ...interface{}) Problem
- func (b *Builder) TooManyRequests(format string, args ...interface{}) Problem
- func (b *Builder) Type(format string, args ...interface{}) *Builder
- func (b *Builder) Unauthorized(format string, args ...interface{}) Problem
- func (b *Builder) Unavailable(format string, args ...interface{}) Problem
- func (b *Builder) UnavailableForLegalReasons(format string, args ...interface{}) Problem
- func (b *Builder) UnprocessableEntity(format string, args ...interface{}) Problem
- func (b *Builder) UnsupportedMediaType(format string, args ...interface{}) Problem
- func (b *Builder) UpgradeRequired(format string, args ...interface{}) Problem
- func (b *Builder) VariantAlsoNegotiates(format string, args ...interface{}) Problem
- type CodeProblem
- type DefaultParams
- type DefaultProblem
- func (p *DefaultProblem) JSON(ctx context.Context, w http.ResponseWriter)
- func (p *DefaultProblem) ProblemStatus() int
- func (p *DefaultProblem) SetDetail(detail string)
- func (p *DefaultProblem) SetInstance(instance string)
- func (p *DefaultProblem) SetParams(url, detail string)
- func (p *DefaultProblem) SetTitle(title string)
- func (p *DefaultProblem) SetType(url string)
- func (p *DefaultProblem) String() string
- func (p *DefaultProblem) Wrap() error
- func (p *DefaultProblem) XML(ctx context.Context, w http.ResponseWriter)
- type InvalidParam
- type MsgFunc
- type Option
- func Code(code string) Option
- func Detail(detail string) Option
- func Instance(instance string) Option
- func InvalidParams(err error, params ...InvalidParam) Option
- func Path(req *http.Request) Option
- func Title(title string) Option
- func Type(format string, args ...interface{}) Option
- func ValidationErrors(err error, validErrors ...ValidationError) Option
- type Problem
- func Bind(ctx context.Context, status int, body []byte, f ...func(status int) Problem) (problem Problem, err error)
- func Decode(ctx context.Context, status int, body io.Reader, f ...func(status int) Problem) (problem Problem, err error)
- func Of(ctx context.Context, path string, err error, f ...MsgFunc) Problem
- type ProblemError
- type Renderer
- type ValidationError
Constants ¶
View Source
const (
DefaultType = "about:blank"
)
Variables ¶
This section is empty.
Functions ¶
Types ¶
type BadRequest ¶
type BadRequest struct { *DefaultProblem InvalidParams []InvalidParam `json:"invalid-params,omitempty"` Errors []ValidationError `json:"errors,omitempty"` }
func (*BadRequest) JSON ¶
func (p *BadRequest) JSON(ctx context.Context, w http.ResponseWriter)
func (*BadRequest) Wrap ¶
func (p *BadRequest) Wrap() error
func (*BadRequest) XML ¶
func (p *BadRequest) XML(ctx context.Context, w http.ResponseWriter)
type Builder ¶
type Builder struct {
// contains filtered or unexported fields
}
func (*Builder) BadGateway ¶
func (*Builder) BadRequest ¶
func (*Builder) ExpectationFailed ¶
func (*Builder) FailedDependency ¶
func (*Builder) GatewayTimeout ¶
func (*Builder) HTTPVersionNotSupported ¶
func (*Builder) InsufficientStorage ¶
func (*Builder) InternalServerError ¶
func (*Builder) LengthRequired ¶
func (*Builder) LoopDetected ¶
func (*Builder) MethodNotAllowed ¶
func (*Builder) MisdirectedRequest ¶
func (*Builder) NetworkAuthenticationRequired ¶
func (*Builder) NotAcceptable ¶
func (*Builder) NotExtended ¶
func (*Builder) NotImplemented ¶
func (*Builder) PaymentRequired ¶
func (*Builder) PreconditionFailed ¶
func (*Builder) PreconditionRequired ¶
func (*Builder) ProxyAuthRequired ¶
func (*Builder) RequestEntityTooLarge ¶
func (*Builder) RequestHeaderFieldsTooLarge ¶
func (*Builder) RequestTimeout ¶
func (*Builder) RequestURITooLong ¶
func (*Builder) RequestedRangeNotSatisfiable ¶
func (*Builder) TooManyRequests ¶
func (*Builder) Unauthorized ¶
func (*Builder) Unavailable ¶
func (*Builder) UnavailableForLegalReasons ¶
func (*Builder) UnprocessableEntity ¶
func (*Builder) UnsupportedMediaType ¶
func (*Builder) UpgradeRequired ¶
func (*Builder) VariantAlsoNegotiates ¶
type CodeProblem ¶
type CodeProblem struct { *DefaultProblem Code string `json:"code"` }
func (*CodeProblem) JSON ¶
func (p *CodeProblem) JSON(ctx context.Context, w http.ResponseWriter)
func (*CodeProblem) Wrap ¶
func (p *CodeProblem) Wrap() error
func (*CodeProblem) XML ¶
func (p *CodeProblem) XML(ctx context.Context, w http.ResponseWriter)
type DefaultParams ¶
type DefaultProblem ¶
type DefaultProblem struct { Type string `json:"type"` Title string `json:"title"` Status int `json:"status,omitempty"` Detail string `json:"detail,omitempty"` Instance string `json:"instance,omitempty"` }
func NewProblem ¶
func NewProblem(status int) *DefaultProblem
func (*DefaultProblem) JSON ¶
func (p *DefaultProblem) JSON(ctx context.Context, w http.ResponseWriter)
func (*DefaultProblem) ProblemStatus ¶
func (p *DefaultProblem) ProblemStatus() int
func (*DefaultProblem) SetDetail ¶
func (p *DefaultProblem) SetDetail(detail string)
func (*DefaultProblem) SetInstance ¶
func (p *DefaultProblem) SetInstance(instance string)
func (*DefaultProblem) SetParams ¶
func (p *DefaultProblem) SetParams(url, detail string)
func (*DefaultProblem) SetTitle ¶
func (p *DefaultProblem) SetTitle(title string)
func (*DefaultProblem) SetType ¶
func (p *DefaultProblem) SetType(url string)
func (*DefaultProblem) String ¶
func (p *DefaultProblem) String() string
func (*DefaultProblem) Wrap ¶
func (p *DefaultProblem) Wrap() error
func (*DefaultProblem) XML ¶
func (p *DefaultProblem) XML(ctx context.Context, w http.ResponseWriter)
type InvalidParam ¶
type Option ¶
type Option func(p DefaultParams) Problem
func InvalidParams ¶
func InvalidParams(err error, params ...InvalidParam) Option
InvalidParams Create RFC7807-style validation error messages
func ValidationErrors ¶
func ValidationErrors(err error, validErrors ...ValidationError) Option
ValidationErrors Create RFC9457-style validation error messages.
type ProblemError ¶
type ProblemError struct { Path string // contains filtered or unexported fields }
func (*ProblemError) Error ¶
func (err *ProblemError) Error() string
func (*ProblemError) Problem ¶
func (err *ProblemError) Problem() Problem
func (*ProblemError) Unwrap ¶ added in v0.1.2
func (err *ProblemError) Unwrap() error
type Renderer ¶
type Renderer interface { JSON(ctx context.Context, w http.ResponseWriter) XML(ctx context.Context, w http.ResponseWriter) Wrap() error }
type ValidationError ¶
Click to show internal directories.
Click to hide internal directories.