http

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Aug 10, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var LogFormat = "" /* 131-byte string literal not displayed */
View Source
var StatusCodeDescription = map[int]string{
	100: "Continue",
	101: "Switching Protocols",
	102: "Processing",
	103: "Early Hints",
	200: "OK",
	201: "Created",
	202: "Accepted",
	203: "Non-Authoritative Information",
	204: "No Content",
	205: "Reset Content",
	206: "Partial Content",
	207: "Multi-Status",
	208: "Already Reported",
	226: "IM Used",
	300: "Multiple Choices",
	301: "Moved Permanently",
	302: "Found",
	303: "See Other",
	304: "Not Modified",
	305: "Use Proxy",
	306: "(Unused)",
	307: "Temporary Redirect",
	308: "Permanent Redirect",
	400: "Bad Request",
	401: "Unauthorized",
	402: "Payment Required",
	403: "Forbidden",
	404: "Not Found",
	405: "Method Not Allowed",
	406: "Not Acceptable",
	407: "Proxy Authentication Required",
	408: "Request Timeout",
	409: "Conflict",
	410: "Gone",
	411: "Length Required",
	412: "Precondition Failed",
	413: "Payload Too Large",
	414: "URI Too Long",
	415: "Unsupported Media Type",
	416: "Range Not Satisfiable",
	417: "Expectation Failed",
	421: "Misdirected Request",
	422: "Unprocessable Entity",
	423: "Locked",
	424: "Failed Dependency",
	425: "Too Early",
	426: "Upgrade Required",
	427: "Unassigned",
	428: "Precondition Required",
	429: "Too Many Requests",
	430: "Unassigned",
	431: "Request Header Fields Too Large",
	451: "Unavailable For Legal Reasons",
	500: "Internal Server Error",
	501: "Not Implemented",
	502: "Bad Gateway",
	503: "Service Unavailable",
	504: "Gateway Timeout",
	505: "HTTP Version Not Supported",
	506: "Variant Also Negotiates",
	507: "Insufficient Storage",
	508: "Loop Detected",
	509: "Unassigned",
	510: "Not Extended",
	511: "Network Authentication Required",
}

https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml

Functions

func Handler

func Handler(statusCode int, responseText string, headers map[string]string) func(w http.ResponseWriter, r *http.Request)

func Listener added in v0.10.0

func Listener(address string) func() error

func ListenerTLS added in v0.10.0

func ListenerTLS(address, certFile, keyFile string) func() error

func Serve

func Serve(listener func() error, code int, body string, headers map[string]string)

Types

type LogContext added in v0.8.0

type LogContext struct {
	ResponseContext
}

type ResponseContext

type ResponseContext struct {
	Host       string
	StatusCode int

	Method string
	Proto  string
	Path   string
	// contains filtered or unexported fields
}

func (ResponseContext) Description

func (r ResponseContext) Description() string

func (ResponseContext) RequestHeader

func (r ResponseContext) RequestHeader(key string) string

Return values for the given header key. Concatenate multiple values associated with a key into a comma seperated string

func (ResponseContext) RequestHeaders

func (r ResponseContext) RequestHeaders() []headerField

Return all header keys and values sorted by key. Concatenate multiple values associated with a key into a comma seperated string

Jump to

Keyboard shortcuts

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