Documentation ¶
Overview ¶
Package problems 提供对 Problem 相关内容的管理
Index ¶
- Constants
- func IsValidStatus(status int) bool
- func Status(id string) int
- type Problems
- type RFC7807
- func (p *RFC7807[C]) AddParam(name string, reason string)
- func (p *RFC7807[C]) Apply(ctx C)
- func (p *RFC7807[C]) MarshalForm() ([]byte, error)
- func (p *RFC7807[C]) MarshalHTML() (string, any)
- func (p *RFC7807[C]) MarshalJSON() ([]byte, error)
- func (p *RFC7807[C]) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (p *RFC7807[C]) With(key string, val any)
- type RFC7807Pool
Constants ¶
View Source
const ( // 特殊值,当不希望显示 type 值时,将 type 赋予此值,不应该出现相应的状态码。 ProblemAboutBlank = "about:blank" // 400 ProblemBadRequest = "400" ProblemPaymentRequired = "402" ProblemForbidden = "403" ProblemNotFound = "404" ProblemMethodNotAllowed = "405" ProblemNotAcceptable = "406" ProblemProxyAuthRequired = "407" ProblemRequestTimeout = "408" ProblemConflict = "409" ProblemGone = "410" ProblemLengthRequired = "411" ProblemPreconditionFailed = "412" ProblemRequestEntityTooLarge = "413" ProblemRequestURITooLong = "414" ProblemUnsupportedMediaType = "415" ProblemRequestedRangeNotSatisfiable = "416" ProblemExpectationFailed = "417" ProblemTeapot = "418" ProblemMisdirectedRequest = "421" ProblemUnprocessableEntity = "422" ProblemLocked = "423" ProblemFailedDependency = "424" ProblemTooEarly = "425" ProblemUpgradeRequired = "426" ProblemPreconditionRequired = "428" ProblemTooManyRequests = "429" ProblemRequestHeaderFieldsTooLarge = "431" // 500 ProblemInternalServerError = "500" ProblemNotImplemented = "501" ProblemBadGateway = "502" ProblemGatewayTimeout = "504" ProblemHTTPVersionNotSupported = "505" ProblemVariantAlsoNegotiates = "506" ProblemInsufficientStorage = "507" ProblemLoopDetected = "508" ProblemNotExtended = "510" ProblemNetworkAuthenticationRequired = "511" )
预定义的 Problem id 值
Variables ¶
This section is empty.
Functions ¶
func IsValidStatus ¶ added in v0.70.0
Types ¶
type Problems ¶
type Problems[P any] struct { // contains filtered or unexported fields }
Problems 管理 Problem
P 表示 Problem 接口类型
func (*Problems[P]) Add ¶
func (p *Problems[P]) Add(id string, status int, title, detail localeutil.LocaleStringer)
func (*Problems[P]) Problem ¶
func (p *Problems[P]) Problem(printer *localeutil.Printer, id string) P
func (*Problems[P]) Visit ¶ added in v0.70.0
func (p *Problems[P]) Visit(visit func(prefix, id string, status int, title, detail localeutil.LocaleStringer))
type RFC7807 ¶
type RFC7807[C ctx] struct {
// contains filtered or unexported fields
}
RFC7807 server.Problem 接口的 rfc7807 实现
C 表示实现的 server.Context 类型, 因为此类型最终会被 server 包引用,为了拆分代码,用泛型代替。
func (*RFC7807[C]) MarshalForm ¶
func (*RFC7807[C]) MarshalHTML ¶
func (*RFC7807[C]) MarshalJSON ¶
func (*RFC7807[C]) MarshalXML ¶
type RFC7807Pool ¶
type RFC7807Pool[C ctx] struct {
// contains filtered or unexported fields
}
func NewRFC7807Pool ¶
func NewRFC7807Pool[C ctx]() *RFC7807Pool[C]
Click to show internal directories.
Click to hide internal directories.