Documentation
¶
Overview ¶
BSD licence at https://github.com/julienschmidt/httprouter/blob/master/LICENSE
Index ¶
- Constants
- func CleanPath(p string) string
- type App
- func (a *App) Debug(isDebug bool)
- func (a *App) Handler() http.Handler
- func (a *App) Listener(listener net.Listener) error
- func (app *App) NoRoute(handlers ...HandlerFunc)
- func (a *App) Run(addr string) error
- func (a *App) SetErrorHandler(fc ErrorHandler)
- func (a *App) SetLogger(l Logger)
- func (a *App) SetRender(render Renderer)
- func (a *App) SetValidator(fc Validate, trans ...ValidateTranslate)
- func (a *App) Stop() error
- type Ctx
- func (c *Ctx) Abort()
- func (c *Ctx) AbortWithStatus(code int)
- func (c *Ctx) AppendHeader(key string, values ...string)
- func (c *Ctx) Bind(i interface{}) error
- func (c *Ctx) Blob(code int, contentType string, b []byte) (err error)
- func (c *Ctx) ClientIP() string
- func (c *Ctx) ContentType() string
- func (c *Ctx) Context() context.Context
- func (c *Ctx) Cookie(name string) (*http.Cookie, error)
- func (c *Ctx) Form(key string) string
- func (c *Ctx) Get(key string) (val interface{}, exists bool)
- func (c *Ctx) HTML(code int, html string) error
- func (c *Ctx) HTMLBlob(code int, b []byte) (err error)
- func (c *Ctx) HandleError(err error)
- func (c *Ctx) Header(key string) string
- func (c *Ctx) IsDebug() bool
- func (c *Ctx) JSON(code int, i interface{}) error
- func (c *Ctx) JSONP(code int, i interface{}) error
- func (c *Ctx) Logger() Logger
- func (c *Ctx) Next() error
- func (c *Ctx) Param(key string) string
- func (c *Ctx) Query(key string) string
- func (c *Ctx) Redirect(location string, code ...int) error
- func (c *Ctx) RemoteIP() string
- func (c *Ctx) RoutePath() string
- func (c *Ctx) Set(key string, val interface{})
- func (c *Ctx) SetCookie(name, value string, maxAge int, path, domain string, secure, httpOnly bool)
- func (c *Ctx) SetHeader(key, value string)
- func (c *Ctx) SetSameSite(samesite http.SameSite)
- func (c *Ctx) Status(code int)
- func (c *Ctx) String(code int, s string) error
- func (c *Ctx) View(code int, name string, data interface{}) error
- func (c *Ctx) XML(code int, i interface{}) error
- type ErrorCode
- type ErrorHandler
- type Group
- func (g *Group) Any(path string, handlers ...HandlerFunc) Router
- func (g *Group) DELETE(path string, handlers ...HandlerFunc) Router
- func (g *Group) GET(path string, handlers ...HandlerFunc) Router
- func (g *Group) Group(relativePath string, handlers ...HandlerFunc) Router
- func (g *Group) HEAD(path string, handlers ...HandlerFunc) Router
- func (g *Group) Handle(method string, path string, handlers ...HandlerFunc) Router
- func (g *Group) OPTIONS(path string, handlers ...HandlerFunc) Router
- func (g *Group) PATCH(path string, handlers ...HandlerFunc) Router
- func (g *Group) POST(path string, handlers ...HandlerFunc) Router
- func (g *Group) PUT(path string, handlers ...HandlerFunc) Router
- func (g *Group) Static(relativePath, root string) Router
- func (g *Group) StaticFS(relativePath string, fsys http.FileSystem) Router
- func (g *Group) StaticFile(relativePath, filePath string) Router
- func (g *Group) TRACE(path string, handlers ...HandlerFunc) Router
- func (g *Group) Use(middlewares ...HandlerFunc)
- type HandlerFunc
- type LogLevel
- type Logger
- type Map
- type Param
- type Params
- type Renderer
- type ResponseWriter
- type Router
- type Validate
- type ValidateTranslate
Constants ¶
View Source
const ( MIMEJSON = "application/json" MIMEHTML = "text/html" MIMEXML = "application/xml" MIMEXML2 = "text/xml" MIMEPlain = "text/plain" MIMEPOSTForm = "application/x-www-form-urlencoded" MIMEMultipartPOSTForm = "multipart/form-data" MIMEPROTOBUF = "application/x-protobuf" MIMEYAML = "application/x-yaml" )
View Source
const ( HeaderContentLength = "Content-Length" HeaderOrigin = "Origin" HeaderVary = "Vary" HeaderXForwardedFor = "X-Forwarded-For" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXRealIP = "X-Real-Ip" HeaderXRequestID = "X-Request-ID" // 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" )
Variables ¶
This section is empty.
Functions ¶
func CleanPath ¶
CleanPath is the URL version of path.Clean, it returns a canonical URL path for p, eliminating . and .. elements.
The following rules are applied iteratively until no further processing can be done:
- Replace multiple slashes with a single slash.
- Eliminate each . path name element (the current directory).
- Eliminate each inner .. path name element (the parent directory) along with the non-.. element that precedes it.
- Eliminate .. elements that begin a rooted path: that is, replace "/.." by "/" at the beginning of a path.
If the result of this process is an empty string, "/" is returned
Types ¶
type App ¶
func (*App) NoRoute ¶
func (app *App) NoRoute(handlers ...HandlerFunc)
func (*App) SetErrorHandler ¶
func (a *App) SetErrorHandler(fc ErrorHandler)
func (*App) SetValidator ¶
func (a *App) SetValidator(fc Validate, trans ...ValidateTranslate)
type Ctx ¶
type Ctx struct {
Response ResponseWriter
Request *http.Request
Params Params
// contains filtered or unexported fields
}
func (*Ctx) AbortWithStatus ¶
func (*Ctx) AppendHeader ¶
func (*Ctx) ContentType ¶
func (*Ctx) HandleError ¶
func (*Ctx) SetSameSite ¶
type ErrorHandler ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
func (*Group) Handle ¶
func (g *Group) Handle(method string, path string, handlers ...HandlerFunc) Router
func (*Group) StaticFile ¶
func (*Group) Use ¶
func (g *Group) Use(middlewares ...HandlerFunc)
type HandlerFunc ¶
type Logger ¶
type Logger interface {
SetLevel(level string)
Debug(v ...interface{})
Info(v ...interface{})
Warn(v ...interface{})
Error(v ...interface{})
Debugf(format string, v ...interface{})
Infof(format string, v ...interface{})
Warnf(format string, v ...interface{})
Errorf(format string, v ...interface{})
}
type ResponseWriter ¶
type Router ¶
type Router interface {
GET(path string, handlers ...HandlerFunc) Router
POST(path string, handlers ...HandlerFunc) Router
PUT(path string, handlers ...HandlerFunc) Router
DELETE(path string, handlers ...HandlerFunc) Router
HEAD(path string, handlers ...HandlerFunc) Router
PATCH(path string, handlers ...HandlerFunc) Router
OPTIONS(path string, handlers ...HandlerFunc) Router
TRACE(path string, handlers ...HandlerFunc) Router
Handle(method string, path string, handlers ...HandlerFunc) Router
Any(path string, handlers ...HandlerFunc) Router
Static(relativePath, root string) Router
StaticFS(relativePath string, fsys http.FileSystem) Router
StaticFile(relativePath, filePath string) Router
Group(relativePath string, handlers ...HandlerFunc) Router
Use(middlewares ...HandlerFunc)
}
type ValidateTranslate ¶
Source Files
¶
Directories
¶
| Path | Synopsis |
|---|---|
|
internal
|
|
|
fasttemplate
Package fasttemplate implements simple and fast template library.
|
Package fasttemplate implements simple and fast template library. |
|
middleware
|
|
Click to show internal directories.
Click to hide internal directories.