Documentation ¶
Index ¶
- Constants
- type Accounts
- type Context
- func (c *Context) Abort()
- func (c *Context) AbortWithStatus(code int)
- func (c *Context) Cookie(name string) (string, error)
- func (c *Context) Copy() *Context
- func (c *Context) Data(code int, contentType string, data []byte)
- func (c *Context) File(filePath string)
- func (c *Context) Get(key string) (value any, ok bool)
- func (c *Context) HTML(code int, name string, data any)
- func (c *Context) HandlerName() string
- func (c *Context) JSON(code int, obj any)
- func (c *Context) MustGet(key string) any
- func (c *Context) Next()
- func (c *Context) Param(key string) string
- func (c *Context) PostForm(key string) string
- func (c *Context) Query(key string) string
- func (c *Context) Redirect(location string)
- func (c *Context) RemoteIP() string
- func (c *Context) Set(key string, value any)
- func (c *Context) SetCookie(name string, value string, maxAge int, path string, domain string, secure bool, ...)
- func (c *Context) SetHeader(key, value string)
- func (c *Context) Status(code int)
- func (c *Context) String(code int, format string, a ...any)
- type Engine
- func (e *Engine) LoadHTMLFiles(files ...string)
- func (e *Engine) LoadHTMLGlob(path string)
- func (e *Engine) Run(addr string) error
- func (e *Engine) RunTLS(addr, certFile, keyFile string) error
- func (e *Engine) ServeHTTP(w http.ResponseWriter, req *http.Request)
- func (e *Engine) SetFuncMap(funcMap template.FuncMap)
- type H
- type HandlerFunc
- type RouterGroup
- func (g *RouterGroup) Any(path string, handlers ...HandlerFunc)
- func (g *RouterGroup) CONNECT(path string, handlers ...HandlerFunc)
- func (g *RouterGroup) DELETE(path string, handlers ...HandlerFunc)
- func (g *RouterGroup) GET(path string, handlers ...HandlerFunc)
- func (g *RouterGroup) Group(prefix string, handlers ...HandlerFunc) *RouterGroup
- func (g *RouterGroup) HEAD(path string, handlers ...HandlerFunc)
- func (g *RouterGroup) OPTIONS(path string, handlers ...HandlerFunc)
- func (g *RouterGroup) PATCH(path string, handlers ...HandlerFunc)
- func (g *RouterGroup) POST(path string, handlers ...HandlerFunc)
- func (g *RouterGroup) Static(relativePath, root string)
- func (g *RouterGroup) TRACE(path string, handlers ...HandlerFunc)
- func (g *RouterGroup) Use(middlewares ...HandlerFunc)
Constants ¶
const ( MIMEJSON = "application/json" MIMEHTML = "text/html" MIMEPlain = "text/plain" MIMEPOSTForm = "application/x-www-form-urlencoded" MIMEMultipart = "multipart/form-data" )
const AuthProxyUserKey = "proxy_user"
const AuthUserKey = "user"
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context struct { Writer http.ResponseWriter Request *http.Request Path string Method string Params httprouter.Params Keys map[string]any StatusCode int Errors []*error // Errors is a list of errors attached to all the handlers/middlewares // contains filtered or unexported fields }
func (*Context) Abort ¶ added in v0.2.0
func (c *Context) Abort()
Abort Note that this will not stop the current handler, often followed by `return`
func (*Context) AbortWithStatus ¶ added in v0.3.0
func (*Context) Copy ¶ added in v0.5.0
Copy returns a copy of the current context that can be safely used outside the request's scope. This has to be used when the context has to be passed to a goroutine.
func (*Context) HandlerName ¶ added in v0.5.0
HandlerName returns the main handler's name
type Engine ¶
type Engine struct { *RouterGroup // contains filtered or unexported fields }
func (*Engine) LoadHTMLFiles ¶ added in v0.3.0
func (*Engine) LoadHTMLGlob ¶ added in v0.2.0
func (*Engine) SetFuncMap ¶ added in v0.1.1
SetFuncMap assume that only invoke one time
type HandlerFunc ¶
type HandlerFunc func(c *Context)
func BasicAuth ¶ added in v0.3.1
func BasicAuth(accounts Accounts) HandlerFunc
BasicAuth returns a Basic HTTP Authorization middleware.
func BasicAuthForProxy ¶ added in v0.3.1
func BasicAuthForProxy(accounts Accounts) HandlerFunc
BasicAuthForProxy returns a Basic HTTP Proxy Authorization middleware.
func BasicAuthForProxyWithRealm ¶ added in v0.3.1
func BasicAuthForProxyWithRealm(accounts Accounts, realm string) HandlerFunc
BasicAuthForProxyWithRealm If the realm is empty, "Proxy Authorization Required" will be used by default.
func BasicAuthWithRealm ¶ added in v0.3.1
func BasicAuthWithRealm(accounts Accounts, realm string) HandlerFunc
BasicAuthWithRealm If the realm is empty, "Authorization Required" will be used by default.
func Recovery ¶ added in v0.2.0
func Recovery() HandlerFunc
type RouterGroup ¶ added in v0.1.1
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) Any ¶ added in v0.2.0
func (g *RouterGroup) Any(path string, handlers ...HandlerFunc)
func (*RouterGroup) CONNECT ¶ added in v0.2.0
func (g *RouterGroup) CONNECT(path string, handlers ...HandlerFunc)
func (*RouterGroup) DELETE ¶ added in v0.2.0
func (g *RouterGroup) DELETE(path string, handlers ...HandlerFunc)
func (*RouterGroup) GET ¶ added in v0.1.1
func (g *RouterGroup) GET(path string, handlers ...HandlerFunc)
func (*RouterGroup) Group ¶ added in v0.1.1
func (g *RouterGroup) Group(prefix string, handlers ...HandlerFunc) *RouterGroup
func (*RouterGroup) HEAD ¶ added in v0.2.0
func (g *RouterGroup) HEAD(path string, handlers ...HandlerFunc)
func (*RouterGroup) OPTIONS ¶ added in v0.2.0
func (g *RouterGroup) OPTIONS(path string, handlers ...HandlerFunc)
func (*RouterGroup) PATCH ¶ added in v0.2.0
func (g *RouterGroup) PATCH(path string, handlers ...HandlerFunc)
func (*RouterGroup) POST ¶ added in v0.1.1
func (g *RouterGroup) POST(path string, handlers ...HandlerFunc)
func (*RouterGroup) Static ¶ added in v0.1.1
func (g *RouterGroup) Static(relativePath, root string)
func (*RouterGroup) TRACE ¶ added in v0.2.0
func (g *RouterGroup) TRACE(path string, handlers ...HandlerFunc)
func (*RouterGroup) Use ¶ added in v0.1.1
func (g *RouterGroup) Use(middlewares ...HandlerFunc)