httpresponse

package
v1.5.4 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2025 License: Apache-2.0 Imports: 8 Imported by: 9 modules, 57 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	ErrBadRequest     = Err(http.StatusBadRequest)
	ErrNotFound       = Err(http.StatusNotFound)
	ErrConflict       = Err(http.StatusConflict)
	ErrNotImplemented = Err(http.StatusNotImplemented)
	ErrInternalError  = Err(http.StatusInternalServerError)
)

Variables

This section is empty.

Functions

func Attachment

func Attachment(w http.ResponseWriter, r io.Reader, code int, params map[string]string) error

Attachment will write out an attachment from a io.Reader

func Cors

func Cors(w http.ResponseWriter, r *http.Request, origin string, methods ...string)

Write the cors headers

func Empty

func Empty(w http.ResponseWriter, code int) error

Empty is a utility function to serve an empty response

func Error

func Error(w http.ResponseWriter, err error, detail ...any) error

Error writes an error from a HTTP status code, with additional detail

func JSON

func JSON(w http.ResponseWriter, code, indent int, v any) error

JSON will write a JSON response to the writer with a HTTP status code, optionally indenting the JSON by a number of spaces

Types

type Err

type Err int

Err turns a HTTP status code into an error

func (Err) Error

func (code Err) Error() string

func (Err) With

func (code Err) With(args ...interface{}) error

func (Err) Withf

func (code Err) Withf(format string, args ...interface{}) error

Jump to

Keyboard shortcuts

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