httpresponse

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: Jul 26, 2024 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ContentTypeKey   = "Content-Type"
	ContentLengthKey = "Content-Length"
	ContentTypeJSON  = "application/json"
	ContentTypeText  = "text/plain"
)

Variables

This section is empty.

Functions

func Cors

func Cors(w http.ResponseWriter, origin string)

Cors is a utility function to set the CORS headers on a pre-flight request

func Empty

func Empty(w http.ResponseWriter, code int)

Empty is a utility function to serve an empty response

func Error

func Error(w http.ResponseWriter, code int, reason ...string) error

Error is a utility function to serve a JSON error notice

func JSON

func JSON(w http.ResponseWriter, v interface{}, code int, indent uint) error

JSON is a utility function to serve an arbitary object as JSON

func Text

func Text(w http.ResponseWriter, v string, code int)

Text is a utility function to serve plaintext

Types

This section is empty.

Jump to

Keyboard shortcuts

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