Documentation ¶
Index ¶
- Constants
- func ConvertPhpQuery(u url.Values) map[string]any
- func EncodePhpQuery(q map[string]any) string
- func ErrorHandler(f http.Handler) error
- func ErrorHandlerFunc(f func(w http.ResponseWriter, req *http.Request)) error
- func ErrorToHttpHandler(e error) http.Handler
- func Get(url string) (io.ReadCloser, error)
- func HTTPStatus(err error) int
- func HttpErrorHandler(code int) http.Handlerdeprecated
- func HttpHandlerToError(h http.Handler) error
- func IsRedirect(e error) http.Handler
- func ParseDataUri(u string) ([]byte, string, error)
- func ParseIPPort(ip string) *net.TCPAddr
- func ParsePhpQuery(q string) map[string]any
- func RedirectError(u *url.URL) error
- func RedirectErrorCode(u *url.URL, code int) error
- func SendRedirect(w http.ResponseWriter, target string, code int)
- func ServeError(w http.ResponseWriter, req *http.Request, err error)
- func Wrap(h Handler) http.Handler
- type Handler
- type HttpError
- type Redirect
- type WrapFunc
- type Wrapper
Constants ¶
const ( StatusBadRequest = HttpError(http.StatusBadRequest) StatusPaymentRequired = HttpError(http.StatusPaymentRequired) StatusForbidden = HttpError(http.StatusForbidden) StatusNotFound = HttpError(http.StatusNotFound) StatusMethodNotAllowed = HttpError(http.StatusMethodNotAllowed) StatusNotAcceptable = HttpError(http.StatusNotAcceptable) StatusProxyAuthRequired = HttpError(http.StatusProxyAuthRequired) StatusRequestTimeout = HttpError(http.StatusRequestTimeout) StatusConflict = HttpError(http.StatusConflict) StatusGone = HttpError(http.StatusGone) StatusLengthRequired = HttpError(http.StatusLengthRequired) StatusPreconditionFailed = HttpError(http.StatusPreconditionFailed) StatusRequestEntityTooLarge = HttpError(http.StatusRequestEntityTooLarge) StatusRequestURITooLong = HttpError(http.StatusRequestURITooLong) StatusUnsupportedMediaType = HttpError(http.StatusUnsupportedMediaType) StatusRequestedRangeNotSatisfiable = HttpError(http.StatusRequestedRangeNotSatisfiable) StatusExpectationFailed = HttpError(http.StatusExpectationFailed) StatusTeapot = HttpError(http.StatusTeapot) StatusMisdirectedRequest = HttpError(http.StatusMisdirectedRequest) StatusUnprocessableEntity = HttpError(http.StatusUnprocessableEntity) StatusLocked = HttpError(http.StatusLocked) StatusFailedDependency = HttpError(http.StatusFailedDependency) StatusTooEarly = HttpError(http.StatusTooEarly) StatusUpgradeRequired = HttpError(http.StatusUpgradeRequired) StatusPreconditionRequired = HttpError(http.StatusPreconditionRequired) StatusTooManyRequests = HttpError(http.StatusTooManyRequests) StatusRequestHeaderFieldsTooLarge = HttpError(http.StatusRequestHeaderFieldsTooLarge) StatusInternalServerError = HttpError(http.StatusInternalServerError) StatusNotImplemented = HttpError(http.StatusNotImplemented) StatusBadGateway = HttpError(http.StatusBadGateway) StatusGatewayTimeout = HttpError(http.StatusGatewayTimeout) StatusHTTPVersionNotSupported = HttpError(http.StatusHTTPVersionNotSupported) StatusVariantAlsoNegotiates = HttpError(http.StatusVariantAlsoNegotiates) StatusInsufficientStorage = HttpError(http.StatusInsufficientStorage) StatusLoopDetected = HttpError(http.StatusLoopDetected) StatusNotExtended = HttpError(http.StatusNotExtended) StatusNetworkAuthenticationRequired = HttpError(http.StatusNetworkAuthenticationRequired) )
Variables ¶
This section is empty.
Functions ¶
func EncodePhpQuery ¶
func ErrorHandler ¶ added in v0.0.2
ErrorHandler returns an error that also complies with http.Handler for a given http.Handler.
func ErrorHandlerFunc ¶ added in v0.0.2
func ErrorHandlerFunc(f func(w http.ResponseWriter, req *http.Request)) error
ErrorHandlerFunc returns an error that also complies with http.Handler for a given function.
func ErrorToHttpHandler ¶
func Get ¶ added in v0.2.1
func Get(url string) (io.ReadCloser, error)
Get will perform a GET on the specified URL and return an object that will read data and automatically resume the download if an error occurs. Additionally it will also check the HTTP Status and return an error if it is not successful.
If the response does not contain a Content-Length or if the server does not support Range headers, this will just perform a regular GET and won't be able to resume anything.
func HTTPStatus ¶ added in v0.0.5
func HttpErrorHandler
deprecated
func HttpHandlerToError ¶
func IsRedirect ¶
func ParseDataUri ¶
ParseDataUri will parse a given data: uri and return its data and mime type.
func ParseIPPort ¶
ParseIPPort will parse an IP with optionally a port
func ParsePhpQuery ¶
ParsePhpQuery parses PHP compatible query string, return as map[string]any
multiple cases may happen: a=b (simple) a[b]=c (object) a[]=c (array) a[b][]=c (multi levels) a[][][]=c (wtf)
func RedirectError ¶
func RedirectErrorCode ¶
code can be one of http.StatusMovedPermanently or http.StatusFound or any 3xx http status code
func SendRedirect ¶
func SendRedirect(w http.ResponseWriter, target string, code int)
SendRedirect is deprecated. http.Redirect() should be used instead
func ServeError ¶
func ServeError(w http.ResponseWriter, req *http.Request, err error)
Types ¶
type Handler ¶ added in v0.0.8
type Handler interface {
ServeHTTP(w http.ResponseWriter, req *http.Request) error
}
type HttpError ¶
type HttpError int
func (HttpError) Error ¶ added in v0.0.4
Error returns information about the error, including the corresponding text
func (HttpError) HTTPStatus ¶ added in v0.0.5
HTTPStatus returns the value set in http error