Documentation
¶
Index ¶
- Constants
- Variables
- func Normalize(header string) string
- type Context
- func (c *Context) Clean()
- func (c *Context) Close()
- func (c *Context) Cookie(key string) string
- func (c *Context) Data(code int, data []byte)
- func (c *Context) Delete(key string)
- func (c *Context) End()
- func (c *Context) File(code int, ffs fs.FS, filename string)
- func (c *Context) Get(key string) (value interface{}, ok bool)
- func (c *Context) Hijacker(f func(bufrw *bufio.ReadWriter) error) error
- func (c *Context) Index() int
- func (c *Context) JSON(code int, obj any)
- func (c *Context) Next()
- func (c *Context) PostForm(key string) string
- func (c *Context) Query(key string) string
- func (c *Context) ReqBody() (body []byte)
- func (c *Context) Response() (http.ResponseWriter, error)
- func (c *Context) ResponseExported() bool
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetHeader(key string, value string)
- func (c *Context) Sprintf(code int, format string, values ...any)
- func (c *Context) Status(code ...int) int
- func (c *Context) String(code int, format string)
- func (c *Context) WriteTo(w io.Writer) (int64, error)
- func (c *Context) XML(code int, obj any)
- type Group
- func (g *Group) Any(part string, handler HandlerFunc)
- func (g *Group) Delete(part string, handler HandlerFunc)
- func (g *Group) Get(part string, handler HandlerFunc)
- func (g *Group) GroupTx(prefix string, f func(g *Group))
- func (g *Group) Head(part string, handler HandlerFunc)
- func (g *Group) Method(method, part string, handler HandlerFunc)
- func (g *Group) NewGroup(prefix string) *Group
- func (g *Group) Object(part string, object interface{})
- func (g *Group) Options(part string, handler HandlerFunc)
- func (g *Group) Patch(part string, handler HandlerFunc)
- func (g *Group) Post(part string, handler HandlerFunc)
- func (g *Group) Put(part string, handler HandlerFunc)
- func (g *Group) Use(middleware ...HandlerFunc)
- type HandlerFunc
- type HandlerList
- type HandlerWriter
- type Tux
Constants ¶
View Source
const ( HeaderAccept = "Accept" HeaderAcceptCharset = "Accept-Charset" HeaderAcceptEncoding = "Accept-Encoding" HeaderAcceptLanguage = "Accept-Language" HeaderAuthorization = "Authorization" HeaderCacheControl = "Cache-Control" HeaderContentLength = "Content-Length" HeaderContentMD5 = "Content-MD5" HeaderContentType = "Content-Type" HeaderDoNotTrack = "DNT" HeaderIfMatch = "If-Match" HeaderIfModifiedSince = "If-Modified-Since" HeaderIfNoneMatch = "If-None-Match" HeaderIfRange = "If-Range" HeaderIfUnmodifiedSince = "If-Unmodified-Since" HeaderMaxForwards = "Max-Forwards" HeaderProxyAuthorization = "Proxy-Authorization" HeaderPragma = "Pragma" HeaderRange = "Range" HeaderReferer = "Referer" HeaderUserAgent = "User-Agent" HeaderTE = "TE" HeaderVia = "Via" HeaderWarning = "Warning" HeaderCookie = "Cookie" HeaderOrigin = "Origin" HeaderAcceptDatetime = "Accept-Datetime" HeaderXRequestedWith = "X-Requested-With" 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" HeaderAccessControlRequestMethod = "Access-Control-Request-Method" HeaderAccessControlRequestHeaders = "Access-Control-Request-Headers" HeaderAcceptPatch = "Accept-Patch" HeaderAcceptRanges = "Accept-Ranges" HeaderAllow = "Allow" HeaderContentEncoding = "Content-Encoding" HeaderContentLanguage = "Content-Language" HeaderContentLocation = "Content-Location" HeaderContentDisposition = "Content-Disposition" HeaderContentRange = "Content-Range" HeaderETag = "ETag" HeaderExpires = "Expires" HeaderLastModified = "Last-Modified" HeaderLink = "Link" HeaderLocation = "Location" HeaderP3P = "P3P" HeaderProxyAuthenticate = "Proxy-Authenticate" HeaderRefresh = "Refresh" HeaderRetryAfter = "Retry-After" HeaderServer = "Server" HeaderSetCookie = "Set-Cookie" HeaderStrictTransportSecurity = "Strict-Transport-Security" HeaderTransferEncoding = "Transfer-Encoding" HeaderUpgrade = "Upgrade" HeaderVary = "Vary" HeaderWWWAuthenticate = "WWW-Authenticate" // Non-Standard HeaderXFrameOptions = "X-Frame-Options" HeaderXXSSProtection = "X-XSS-Protection" HeaderContentSecurityPolicy = "Content-Security-Policy" HeaderXContentSecurityPolicy = "X-Content-Security-Policy" HeaderXWebKitCSP = "X-WebKit-CSP" HeaderXContentTypeOptions = "X-Content-Type-Options" HeaderXPoweredBy = "X-Powered-By" HeaderXUACompatible = "X-UA-Compatible" HeaderXForwardedProto = "X-Forwarded-Proto" HeaderXHTTPMethodOverride = "X-HTTP-Method-Override" HeaderXForwardedFor = "X-Forwarded-For" HeaderXRealIP = "X-Real-IP" HeaderXCSRFToken = "X-CSRF-Token" HeaderXRatelimitLimit = "X-Ratelimit-Limit" HeaderXRatelimitRemaining = "X-Ratelimit-Remaining" HeaderXRatelimitReset = "X-Ratelimit-Reset" StatusOK = 200 )
HTTP headers
Variables ¶
View Source
var ( ErrWriterAlreadyExported = errors.New("writer already exported") ErrResponseAlreadySent = errors.New("response already sent") )
Functions ¶
Types ¶
type Context ¶
type Context struct { Req *http.Request // 公开请求 Writer *HandlerWriter // 公开响应 // contains filtered or unexported fields }
Handler 上下文
func (*Context) Close ¶
func (c *Context) Close()
重置请求, 并跳过后续的HandlerFunc 将无任何输出, 并且浏览器显示连接已重置 但是仍然有响应头 "HTTP 1.1 400 Bad Request\r\nConnection: close"
func (*Context) Hijacker ¶
func (c *Context) Hijacker(f func(bufrw *bufio.ReadWriter) error) error
Hijacker 接口封装 用于将writer转换为bufio.ReadWriter 一旦调用此函数, 其他输出函数将无效 并且此函数关闭时将调用End方法结束请求
func (*Context) ResponseExported ¶
type Group ¶
type Group struct {
// contains filtered or unexported fields
}
路由组
func (*Group) Any ¶
func (g *Group) Any(part string, handler HandlerFunc)
func (*Group) Delete ¶
func (g *Group) Delete(part string, handler HandlerFunc)
func (*Group) Get ¶
func (g *Group) Get(part string, handler HandlerFunc)
func (*Group) Head ¶
func (g *Group) Head(part string, handler HandlerFunc)
func (*Group) Method ¶
func (g *Group) Method(method, part string, handler HandlerFunc)
func (*Group) Options ¶
func (g *Group) Options(part string, handler HandlerFunc)
func (*Group) Patch ¶
func (g *Group) Patch(part string, handler HandlerFunc)
func (*Group) Post ¶
func (g *Group) Post(part string, handler HandlerFunc)
func (*Group) Put ¶
func (g *Group) Put(part string, handler HandlerFunc)
func (*Group) Use ¶
func (g *Group) Use(middleware ...HandlerFunc)
type HandlerFunc ¶
type HandlerFunc func(*Context)
type HandlerList ¶
type HandlerList []HandlerFunc
type HandlerWriter ¶
type HandlerWriter struct {
// contains filtered or unexported fields
}
func (*HandlerWriter) Header ¶
func (w *HandlerWriter) Header() http.Header
func (*HandlerWriter) WriteHeader ¶
func (w *HandlerWriter) WriteHeader(code int)
type Tux ¶
type Tux struct { *Group // 路由组 // contains filtered or unexported fields }
func (*Tux) ExportRoute ¶
func (tux *Tux) ExportRoute() []*tree.ExportValue[HandlerList]
Click to show internal directories.
Click to hide internal directories.