Documentation ¶
Index ¶
- Constants
- Variables
- type Context
- type Group
- func (g *Group) Add(method, path string, handlers ...HandlerFunc)
- func (g *Group) Any(path string, handlers ...HandlerFunc)
- func (g *Group) Connect(path string, handlers ...HandlerFunc)
- func (g *Group) Delete(path string, handlers ...HandlerFunc)
- func (g *Group) Get(path string, handlers ...HandlerFunc)
- func (g *Group) Head(path string, handlers ...HandlerFunc)
- func (g *Group) Options(path string, handlers ...HandlerFunc)
- func (g *Group) Patch(path string, handlers ...HandlerFunc)
- func (g *Group) Post(path string, handlers ...HandlerFunc)
- func (g *Group) Put(path string, handlers ...HandlerFunc)
- func (g *Group) Trace(path string, handlers ...HandlerFunc)
- func (g *Group) Use(middlewares ...HandlerFunc)
- type HTTPError
- type HTTPErrorHandler
- type HandlerFunc
- type Jago
- func (j *Jago) Add(method, path string, handlers ...HandlerFunc)
- func (j *Jago) Any(path string, handlers ...HandlerFunc)
- func (j *Jago) Connect(path string, handlers ...HandlerFunc)
- func (j *Jago) DefaultHTTPErrorHandler(err error, c Context)
- func (j *Jago) Delete(path string, handlers ...HandlerFunc)
- func (j *Jago) Get(path string, handlers ...HandlerFunc)
- func (j *Jago) Group(prefix string, handlers ...HandlerFunc) (g *Group)
- func (j *Jago) Head(path string, handlers ...HandlerFunc)
- func (j *Jago) NewContext(r *http.Request, w http.ResponseWriter) Context
- func (j *Jago) Options(path string, handlers ...HandlerFunc)
- func (j *Jago) Patch(path string, handlers ...HandlerFunc)
- func (j *Jago) Post(path string, handlers ...HandlerFunc)
- func (j *Jago) PrintRouter()
- func (j *Jago) Put(path string, handlers ...HandlerFunc)
- func (j *Jago) ServeHTTP(response http.ResponseWriter, request *http.Request)
- func (j *Jago) Trace(path string, handlers ...HandlerFunc)
- func (j *Jago) Use(middlewares ...HandlerFunc)
- type Mached
- type Response
- type Router
- type TreeNode
- type Trie
Constants ¶
View Source
const ( CONNECT = http.MethodConnect DELETE = http.MethodDelete GET = http.MethodGet HEAD = http.MethodHead OPTIONS = http.MethodOptions PATCH = http.MethodPatch POST = http.MethodPost // PROPFIND = "PROPFIND" PUT = http.MethodPut TRACE = http.MethodTrace )
HTTP methods NOTE: Deprecated, please use the stdlib constants directly instead.
View Source
const ( MIMEApplicationJSON = "application/json" MIMEApplicationJSONCharsetUTF8 = MIMEApplicationJSON + "; " + charsetUTF8 MIMEApplicationJavaScript = "application/javascript" MIMEApplicationJavaScriptCharsetUTF8 = MIMEApplicationJavaScript + "; " + charsetUTF8 MIMEApplicationXML = "application/xml" MIMEApplicationXMLCharsetUTF8 = MIMEApplicationXML + "; " + charsetUTF8 MIMETextXML = "text/xml" MIMETextXMLCharsetUTF8 = MIMETextXML + "; " + charsetUTF8 MIMEApplicationForm = "application/x-www-form-urlencoded" MIMEApplicationProtobuf = "application/protobuf" MIMEApplicationMsgpack = "application/msgpack" MIMETextHTML = "text/html" MIMETextHTMLCharsetUTF8 = MIMETextHTML + "; " + charsetUTF8 MIMETextPlain = "text/plain" MIMETextPlainCharsetUTF8 = MIMETextPlain + "; " + charsetUTF8 MIMEMultipartForm = "multipart/form-data" MIMEOctetStream = "application/octet-stream" )
MIME types
View Source
const ( // PROPFIND Method can be used on collection and property resources. PROPFIND = "PROPFIND" // REPORT Method can be used to get information about a resource, see rfc 3253 REPORT = "REPORT" // RouteNotFound is special method type for routes handling "route not found" (404) cases RouteNotFound = "echo_route_not_found" )
View Source
const ( HeaderAccept = "Accept" HeaderAcceptEncoding = "Accept-Encoding" // HeaderAllow is the name of the "Allow" header field used to list the set of methods // advertised as supported by the target resource. Returning an Allow header is mandatory // for status 405 (method not found) and useful for the OPTIONS method in responses. // See RFC 7231: https://datatracker.ietf.org/doc/html/rfc7231#section-7.4.1 HeaderAllow = "Allow" HeaderAuthorization = "Authorization" HeaderContentDisposition = "Content-Disposition" HeaderContentEncoding = "Content-Encoding" HeaderContentLength = "Content-Length" HeaderContentType = "Content-Type" HeaderCookie = "Cookie" HeaderSetCookie = "Set-Cookie" HeaderIfModifiedSince = "If-Modified-Since" HeaderLastModified = "Last-Modified" HeaderLocation = "Location" HeaderRetryAfter = "Retry-After" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderWWWAuthenticate = "WWW-Authenticate" HeaderXForwardedFor = "X-Forwarded-For" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXForwardedProtocol = "X-Forwarded-Protocol" HeaderXForwardedSsl = "X-Forwarded-Ssl" HeaderXUrlScheme = "X-Url-Scheme" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXRealIP = "X-Real-Ip" HeaderXRequestID = "X-Request-Id" HeaderXCorrelationID = "X-Correlation-Id" HeaderXRequestedWith = "X-Requested-With" HeaderServer = "Server" HeaderOrigin = "Origin" HeaderCacheControl = "Cache-Control" HeaderConnection = "Connection" // Access control HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAccessControlAllowOrigin = "Access-Control-Allow-Origin" HeaderAccessControlAllowMethods = "Access-Control-Allow-Methods" HeaderAccessControlAllowHeaders = "Access-Control-Allow-Headers" HeaderAccessControlAllowCredentials = "Access-Control-Allow-Credentials" HeaderAccessControlExposeHeaders = "Access-Control-Expose-Headers" HeaderAccessControlMaxAge = "Access-Control-Max-Age" // Security HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXXSSProtection = "X-XSS-Protection" HeaderXFrameOptions = "X-Frame-Options" HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderContentSecurityPolicyReportOnly = "Content-Security-Policy-Report-Only" HeaderXCSRFToken = "X-CSRF-Token" HeaderReferrerPolicy = "Referrer-Policy" HttpMethodAny = "ANY" Version = "0.0.3" )
Headers
Variables ¶
View Source
var ( ErrUnsupportedMediaType = NewHTTPError(http.StatusUnsupportedMediaType) ErrNotFound = NewHTTPError(http.StatusNotFound) ErrForbidden = NewHTTPError(http.StatusForbidden) ErrMethodNotAllowed = NewHTTPError(http.StatusMethodNotAllowed) ErrStatusRequestEntityTooLarge = NewHTTPError(http.StatusRequestEntityTooLarge) ErrTooManyRequests = NewHTTPError(http.StatusTooManyRequests) ErrBadRequest = NewHTTPError(http.StatusBadRequest) ErrBadGateway = NewHTTPError(http.StatusBadGateway) ErrInternalServerError = NewHTTPError(http.StatusInternalServerError) ErrRequestTimeout = NewHTTPError(http.StatusRequestTimeout) ErrInvalidRedirectCode = errors.New("invalid redirect status code") NotFoundHandler = func(c Context) error { return ErrNotFound } )
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface { Request() *http.Request Next() error Path() string Param(name string) string RealIP() string QueryParam(name string) string QueryParams() url.Values QueryString() string Cookie(name string) (*http.Cookie, error) Cookies() []*http.Cookie BindJson(i interface{}) error HTML(code int, html string) error HTMLBlob(code int, b []byte) error String(code int, s string) error JSON(code int, i interface{}) error JSONPretty(code int, i interface{}, indent string) error XML(code int, i interface{}) error XMLPretty(code int, i interface{}, indent string) error Blob(code int, contentType string, b []byte) error NoContent(code int) error Redirect(code int, url string) error }
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
Group is a set of sub-routes for a specified route.
func (*Group) Add ¶
func (g *Group) Add(method, path string, handlers ...HandlerFunc)
func (*Group) Any ¶
func (g *Group) Any(path string, handlers ...HandlerFunc)
func (*Group) Connect ¶
func (g *Group) Connect(path string, handlers ...HandlerFunc)
func (*Group) Delete ¶
func (g *Group) Delete(path string, handlers ...HandlerFunc)
func (*Group) Get ¶
func (g *Group) Get(path string, handlers ...HandlerFunc)
func (*Group) Head ¶
func (g *Group) Head(path string, handlers ...HandlerFunc)
func (*Group) Options ¶
func (g *Group) Options(path string, handlers ...HandlerFunc)
func (*Group) Patch ¶
func (g *Group) Patch(path string, handlers ...HandlerFunc)
func (*Group) Post ¶
func (g *Group) Post(path string, handlers ...HandlerFunc)
func (*Group) Put ¶
func (g *Group) Put(path string, handlers ...HandlerFunc)
func (*Group) Trace ¶
func (g *Group) Trace(path string, handlers ...HandlerFunc)
func (*Group) Use ¶
func (g *Group) Use(middlewares ...HandlerFunc)
type HTTPError ¶
type HTTPError struct { Code int `json:"-"` Message interface{} `json:"message"` }
func NewHTTPError ¶
type HTTPErrorHandler ¶
type HandlerFunc ¶
type Jago ¶
type Jago struct { HTTPErrorHandler HTTPErrorHandler Debug bool // contains filtered or unexported fields }
func (*Jago) Add ¶
func (j *Jago) Add(method, path string, handlers ...HandlerFunc)
func (*Jago) Any ¶
func (j *Jago) Any(path string, handlers ...HandlerFunc)
func (*Jago) Connect ¶
func (j *Jago) Connect(path string, handlers ...HandlerFunc)
func (*Jago) DefaultHTTPErrorHandler ¶
func (*Jago) Delete ¶
func (j *Jago) Delete(path string, handlers ...HandlerFunc)
func (*Jago) Get ¶
func (j *Jago) Get(path string, handlers ...HandlerFunc)
func (*Jago) Head ¶
func (j *Jago) Head(path string, handlers ...HandlerFunc)
func (*Jago) NewContext ¶
func (*Jago) Options ¶
func (j *Jago) Options(path string, handlers ...HandlerFunc)
func (*Jago) Patch ¶
func (j *Jago) Patch(path string, handlers ...HandlerFunc)
func (*Jago) Post ¶
func (j *Jago) Post(path string, handlers ...HandlerFunc)
func (*Jago) PrintRouter ¶ added in v0.0.2
func (j *Jago) PrintRouter()
func (*Jago) Put ¶
func (j *Jago) Put(path string, handlers ...HandlerFunc)
func (*Jago) ServeHTTP ¶
func (j *Jago) ServeHTTP(response http.ResponseWriter, request *http.Request)
func (*Jago) Trace ¶
func (j *Jago) Trace(path string, handlers ...HandlerFunc)
func (*Jago) Use ¶
func (j *Jago) Use(middlewares ...HandlerFunc)
type Response ¶
type Response struct { Writer http.ResponseWriter Status int Size int64 Committed bool }
func NewResponse ¶
func NewResponse(w http.ResponseWriter) (r *Response)
func (*Response) WriteHeader ¶
Source Files ¶
Click to show internal directories.
Click to hide internal directories.