Documentation
¶
Index ¶
- Constants
- type Option
- type Problem
- func (p *Problem) Append(opts ...Option) *Problem
- func (p Problem) Error() string
- func (p Problem) Is(err error) bool
- func (p Problem) JSON() []byte
- func (p Problem) JSONString() string
- func (p Problem) MarshalJSON() ([]byte, error)
- func (p Problem) MarshalXML(e *xml.Encoder, start xml.StartElement) error
- func (p Problem) UnmarshalJSON(b []byte) error
- func (p *Problem) UnmarshalXML(d *xml.Decoder, start xml.StartElement) error
- func (p Problem) Unwrap() error
- func (p Problem) WriteHeaderTo(w http.ResponseWriter)
- func (p Problem) WriteTo(w http.ResponseWriter) (int, error)
- func (p Problem) WriteXMLHeaderTo(w http.ResponseWriter)
- func (p Problem) WriteXMLTo(w http.ResponseWriter) (int, error)
- func (p Problem) XML() []byte
- func (p Problem) XMLString() string
Constants ¶
const ( // ContentTypeJSON https://tools.ietf.org/html/rfc7807#section-6.1 ContentTypeJSON = "application/problem+json" // ContentTypeXML https://tools.ietf.org/html/rfc7807#section-6.2 ContentTypeXML = "application/problem+xml" )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Option ¶
type Option interface {
// contains filtered or unexported methods
}
An Option configures a Problem using the functional options paradigm popularized by Rob Pike.
func Status ¶
Status sets the HTTP status code generated by the origin server for this occurrence of the problem.
func Title ¶
Title sets a title that appropriately describes it (think short) Written in english and readable for engineers (usually not suited for non technical stakeholders and not localized); example: Service Unavailable
type Problem ¶
type Problem struct {
// contains filtered or unexported fields
}
Problem is an RFC7807 error and can be compared with errors.Is()
func (Problem) JSONString ¶
JSONString returns the Problem as json string
func (Problem) MarshalJSON ¶
MarshalJSON implements the json.Marshaler interface
func (Problem) MarshalXML ¶
MarshalXML implements the xml.Marshaler interface
func (Problem) UnmarshalJSON ¶
UnmarshalJSON implements the json.Unmarshaler interface
func (*Problem) UnmarshalXML ¶
UnmarshalXML implements the xml.Unmarshaler interface
func (Problem) Unwrap ¶
Unwrap returns the result of calling the Unwrap method on err, if err implements Unwrap. Otherwise, Unwrap returns nil.
func (Problem) WriteHeaderTo ¶
func (p Problem) WriteHeaderTo(w http.ResponseWriter)
WriteHeaderTo writes the HTTP headers for the JSON Problem ContentType and the problem's HTTP statuscode. This is suitable for responding to HEAD requests.
func (Problem) WriteTo ¶
func (p Problem) WriteTo(w http.ResponseWriter) (int, error)
WriteTo writes the JSON Problem to an HTTP Response Writer using the correct Content-Type and the problem's HTTP statuscode
func (Problem) WriteXMLHeaderTo ¶
func (p Problem) WriteXMLHeaderTo(w http.ResponseWriter)
WriteXMLHeaderTo writes the HTTP headers for the XML Problem ContentType and the problem's HTTP statuscode. This is suitable for responding to HEAD requests.
func (Problem) WriteXMLTo ¶
func (p Problem) WriteXMLTo(w http.ResponseWriter) (int, error)
WriteXMLTo writes the XML Problem to an HTTP Response Writer using the correct Content-Type and the problem's HTTP statuscode