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

problem

package
v0.4.1 Latest Latest
Warning

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

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

Documentation

Overview

Package problem checks that an error response is a problem details document (RFC 9457): the media type application/problem+json, a JSON object, and the standard members (type, title, status, detail, instance) used as the RFC says. Extension members are allowed and not looked at.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func IsProblemType

func IsProblemType(contentType string) bool

IsProblemType says whether a Content-Type is application/problem+json or application/problem+xml.

Types

type Violation

type Violation struct {
	Path    string
	Message string
}

Violation is one way a response is not a problem details document. Path is "Content-Type" or a JSON path.

func Check

func Check(status int, contentType string, body any) []Violation

Check lists what is wrong with a response of the given HTTP status, Content-Type and decoded JSON body; none means it is a problem details document. An XML problem document is accepted by its media type and its body is not read.

Jump to

Keyboard shortcuts

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