Help us shape the future of Go! Take the 2026 Go Developer Survey

httpx

package
v1.0.7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 11, 2026 License: Apache-2.0 Imports: 2 Imported by: 4

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteProblem

func WriteProblem(w http.ResponseWriter, status int, p Problem)

WriteProblem writes a problem+json response with the provided status code. It merges extension fields after the standard members, per RFC 7807.

func WriteSimpleProblem

func WriteSimpleProblem(w http.ResponseWriter, status int, title, detail string)

WriteSimpleProblem is a convenience for common cases.

Types

type Problem

type Problem struct {
	Type     string         `json:"type,omitempty"`     // "https://example.com/validation-error"`
	Title    string         `json:"title,omitempty"`    // "Bad Request"`
	Status   int            `json:"status,omitempty"`   // 400
	Detail   string         `json:"detail,omitempty"`   // "name is required"
	Instance string         `json:"instance,omitempty"` // "/api/v1/foo/123"
	Ext      map[string]any `json:"-"`
}

Problem represents an RFC 7807 problem+json response body. See: https://datatracker.ietf.org/doc/html/rfc7807

func (*Problem) With

func (p *Problem) With(key string, value any) *Problem

With adds an extension field to the problem payload.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL