{"modulePath":"github.com/weiwolves/pkg","version":"v0.0.0-20200322065615-581c8d33cff6","isLatest":true,"isStandardLibrary":false,"goos":"all","goarch":"all","docs":"# package problem\n\nPackage problem implements the RFC7807 Details for HTTP APIs.\n\nFurther reading [https://tools.ietf.org/html/rfc7807](https://tools.ietf.org/html/rfc7807)\n\n## Constants\n\n```go\nconst (\n\t// MediaType specifies the default media type for a Detail response\n\tMediaType = \"application/problem+json\"\n\n\t// MediaTypeXML specifies the XML variant on the Detail Media type\n\tMediaTypeXML = \"application/problem+xml\"\n\n\t// DefaultURL is the default url to use for problem types\n\tDefaultURL = \"about:blank\"\n)\n```\n\n## Types\n\n```go\ntype Detail struct {\n\t// Type - A URI reference [RFC3986] that identifies the problem type.  This\n\t// specification encourages that, when dereferenced, it provide\n\t// human-readable documentation for the problem type (e.g., using HTML\n\t// [W3C.REC-html5-20141028]).  When this member is not present, its value is\n\t// assumed to be \"about:blank\".\n\tType string `json:\"type\" xml:\"type\"`\n\n\t// Title - A short, human-readable summary of the problem type.  It SHOULD\n\t// NOT change from occurrence to occurrence of the problem, except for\n\t// purposes of localization.\n\tTitle string `json:\"title\" xml:\"title\"`\n\n\t// Status specifies the HTTP status code generated by the origin server for\n\t// this occurrence of the problem.\n\tStatus int `json:\"status,omitempty\" xml:\"status,omitempty\"`\n\n\t// Detail states a human-readable explanation specific to this occurrence of the\n\t// problem.\n\tDetail string `json:\"detail,omitempty\" xml:\"detail,omitempty\"`\n\n\t// Instance states an URI that identifies the specific occurrence of the\n\t// problem. This URI may or may not yield further information if\n\t// dereferenced.\n\tInstance string `json:\"instance,omitempty\" xml:\"instance,omitempty\"`\n\n\t// Cause can reference to the underlying real cause of a problem detail.\n\tCause *Detail `json:\"cause,omitempty\" xml:\"cause,omitempty\"`\n\n\t// Extension defines additional custom key/value pairs in a balanced slice.\n\t// i=key and i+1=value. They will be transformed into a key/value JSON type.\n\tExtension []string\n}\n```\nDetail is a default problem implementation. Problem details are not a debugging tool for the underlying implementation; rather, they are a way to expose greater detail about the HTTP interface itself.  Designers of new problem types need to carefully consider the Security Considerations, in particular, the risk of exposing attack vectors by exposing implementation internals through error messages.\n\n```go\nfunc MustNewDetail(title string, opts ...Option) *Detail\n```\nMustNewDetail same as NewDetail but panics on error.\n\n```go\nfunc NewDetail(title string, opts ...Option) (*Detail, error)\n```\nNewDetail returns a new instance of a Detail problem.\n\n```go\nfunc (v Detail) MarshalEasyJSON(w *jwriter.Writer)\n```\nMarshalEasyJSON supports easyjson.Marshaler interface\n\n```go\nfunc (v Detail) MarshalJSON() ([]byte, error)\n```\nMarshalJSON supports json.Marshaler interface\n\n```go\nfunc (d *Detail) Options(opts ...Option) error\n```\nOptions applies options to the details object.\n\n```go\nfunc (v *Detail) UnmarshalEasyJSON(l *jlexer.Lexer)\n```\nUnmarshalEasyJSON supports easyjson.Unmarshaler interface\n\n```go\nfunc (v *Detail) UnmarshalJSON(data []byte) error\n```\nUnmarshalJSON supports json.Unmarshaler interface\n\n```go\nfunc (d *Detail) Validate() error\n```\nValidate returns an error if the title is empty, or type is not an URI or Extension field is imbalanced.\n\n```go\ntype Option func(*Detail) error\n```\nOption applies an option to the Detail object\n\n```go\nfunc WithCause(title string, opts ...Option) Option\n```\nWithCause adds a detail as a new cause.\n\n```go\nfunc WithExtensionInt(key string, value int) Option\n```\nWithExtensionInt adds an int to the Extension field.\n\n```go\nfunc WithExtensionMapString(m map[string]string) Option\n```\nWithExtensionMapString adds a string only map to the Extension field.\n\n```go\nfunc WithExtensionMapStringSlice(m map[string][]string) Option\n```\nWithExtensionMapStringSlice adds a special map to the Extension field. This kind of map gets implemented by url.Values, http.Header, mail.Header and textproto.MIMEHeader.\n\n```go\nfunc WithExtensionString(keyValues ...string) Option\n```\nWithExtensionString adds one or more key/value pairs to the Extension field.\n\n```go\nfunc WithExtensionUint(key string, value uint64) Option\n```\nWithExtensionUint adds an uint to the Extension field.\n\n","path":"github.com/weiwolves/pkg/net/problem","name":"problem","synopsis":"Package problem implements the RFC7807 Details for HTTP APIs.","isRedistributable":true}
