Documentation
¶
Index ¶
Constants ¶
View Source
const ( HeaderContentType = "Content-Type" HeaderContentLength = "Content-Length" HeaderHost = "Host" HeaderAccept = "Accept" HeaderUserAgent = "User-Agent" HeaderAcceptEncoding = "Accept-Encoding" HeaderAcceptLanguage = "Accept-Language" HeaderConnection = "Connection" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderLocation = "Location" HeaderAuthorization = "Authorization" HeaderCacheControl = "Cache-Control" HeaderOrigin = "Origin" HeaderReferer = "Referer" HeaderTransferEncoding = "Transfer-Encoding" )
Common HTTP header keys
Variables ¶
View Source
var ( // Content type headers HeaderContentTypeJSON = Header{Key: HeaderContentType, Value: "application/json"} HeaderContentTypeHTML = Header{Key: HeaderContentType, Value: "text/html"} HeaderContentTypePlain = Header{Key: HeaderContentType, Value: "text/plain"} HeaderContentTypeXML = Header{Key: HeaderContentType, Value: "application/xml"} HeaderContentTypeForm = Header{Key: HeaderContentType, Value: "application/x-www-form-urlencoded"} HeaderContentTypeMultipart = Header{Key: HeaderContentType, Value: "multipart/form-data"} // Connection headers HeaderConnectionClose = Header{Key: HeaderConnection, Value: "close"} HeaderConnectionKeepAlive = Header{Key: HeaderConnection, Value: "keep-alive"} )
Pre-allocated common headers
Functions ¶
func FindHeader ¶
FindHeader looks for a header by key in a slice of headers
Types ¶
type Context ¶
type Context interface { Bytes([]byte) error Error(...any) error Next() error Redirect(int, string) error Request() Request Response() Response Status(int) Context String(string) error }
Interface for a request and its response.
type Request ¶
type Request interface { Header(string) string Host() string Method() string Path() string Scheme() string Param(string) string Body() []byte }
Interface for HTTP requests.
type Response ¶
type Response interface { io.Writer io.StringWriter Body() []byte Header(string) string SetHeader(key string, value string) SetBody([]byte) SetStatus(int) Status() int }
Interface for an HTTP response.
type Server ¶
type Server interface { Get(path string, handler Handler) Post(path string, handler Handler) Put(path string, handler Handler) Delete(path string, handler Handler) Patch(path string, handler Handler) Request(method string, path string, headers []Header, body io.Reader) Response Router() *router.Router[Handler] Run(address string) error Use(handlers ...Handler) }
Interface for an HTTP server.
Source Files
¶
Click to show internal directories.
Click to hide internal directories.