response

package
v0.0.0-...-82d4db7 Latest Latest
Warning

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

Go to latest
Published: Sep 10, 2024 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package response provides helper functions and structs to respond to API requests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WriteInternalErrorProblemDetails

func WriteInternalErrorProblemDetails(w http.ResponseWriter, logger *slog.Logger)

func WriteJSON

func WriteJSON(w http.ResponseWriter, data any, logger *slog.Logger)

func WriteProblemDetails

func WriteProblemDetails(w http.ResponseWriter, problemDetails ProblemDetails, logger *slog.Logger)

func WriteRequestBodyInvalidProblemDetails

func WriteRequestBodyInvalidProblemDetails(w http.ResponseWriter, err error, logger *slog.Logger)

Types

type ProblemDetails

type ProblemDetails struct {
	Type   string `json:"type,omitempty"`
	Status int    `json:"status,omitempty"`
	Title  string `json:"title,omitempty"`
	Detail string `json:"detail,omitempty"`
}

func NewProblemDetails

func NewProblemDetails(problemDetailsType string, status int, title string, detail string) ProblemDetails

Jump to

Keyboard shortcuts

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