response

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Jun 8, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AddTopLinks(links jsonapi.Links) jsonapi.ResponseOption

AddTopLinks adds links to the top level of the document.

func Created

func Created(resource *jsonapi.Resource, opts ...jsonapi.ResponseOption) jsonapi.Response

Created returns a 201 response containing a JSONAPI document and location header.

func Error

func Error(statusCode int, cause error, opts ...jsonapi.ResponseOption) jsonapi.Response

Error returns a response containing one or more errors.

func InternalError

func InternalError(err error) jsonapi.Response

InternalError sends a JSONAPI formatted 500 error response to the client.

func Ok

Ok returns a 200 response containing a JSONAPI document.

func ResolveRelativeLinkURLs

func ResolveRelativeLinkURLs(baseURL string, resolver jsonapi.URLResolver) jsonapi.ResponseOption

ResolveRelativeLinkURLs traverses the document, affixing the provided base url to any links with relative paths.

func ResourceNotFound

func ResourceNotFound(ctx *jsonapi.RequestContext) jsonapi.Response

ResourceNotFound sends a JSONAPI formatted 404 error response to the client.

func WithErrors

func WithErrors(causes ...error) jsonapi.ResponseOption

WithErrors populates the response document errors field with the provided error messages. If the message is of type jsonapi.ErrorNode, the error will be added directly to the list; otherwise, the error message will be wrapped in a jsonapi.ErrorNode.

func WithHeader

func WithHeader(key, value string) jsonapi.ResponseOption

WithHeader sets the response header.

Types

This section is empty.

Jump to

Keyboard shortcuts

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