Documentation
¶
Index ¶
- Constants
- type AcceptPart
- type App
- func (app *App) Delete(path string, handler Handler)
- func (app *App) Get(path string, handler Handler)
- func (app *App) NewRouter(path string) *Router
- func (app *App) Patch(path string, handler Handler)
- func (app *App) Post(path string, handler Handler)
- func (app *App) Put(path string, handler Handler)
- func (app *App) Start(port int)
- func (app *App) StartTls(port int, certFile, keyFile string)
- func (app *App) Use(args ...any)
- type Cookie
- type Ctx
- type FormFile
- type Handler
- type Middleware
- type MiddlewareWrapper
- type Req
- func (req *Req) Accepts(offered ...string) string
- func (req *Req) AcceptsCharsets(offered ...string) string
- func (req *Req) AcceptsEncodings(offered ...string) string
- func (req *Req) AcceptsLanguages(offered ...string) string
- func (req *Req) App() *App
- func (req *Req) FormFile(name string) (*FormFile, error)
- func (req *Req) FormValue(key string) string
- func (req *Req) Fresh() bool
- func (req *Req) Header(key string) string
- func (req *Req) Host() string
- func (req *Req) Hostname() string
- func (req *Req) IP() string
- func (req *Req) Param(key string) string
- func (req *Req) ParseJson(target any) error
- func (req *Req) Query(key string) string
- func (req *Req) Save(formFile *FormFile, destination string) error
- func (req *Req) Stale() bool
- type Res
- func (res *Res) ClearCookie(key ...string)
- func (res *Res) End()
- func (res *Res) Header(key, value string) *Res
- func (res *Res) Json(data any)
- func (res *Res) Send(data string)
- func (res *Res) SetCookie(cookie Cookie) *Res
- func (res *Res) Static(path, root string)
- func (res *Res) Status(code int) *Res
- func (res *Res) Type(contentType string) *Res
- func (res *Res) Vary(fields ...string)
- type Route
- type Router
- func (router *Router) Delete(path string, handler Handler)
- func (router *Router) Get(path string, handler Handler)
- func (router *Router) Patch(path string, handler Handler)
- func (router *Router) Post(path string, handler Handler)
- func (router *Router) Put(path string, handler Handler)
- func (router *Router) Use(args ...any)
Constants ¶
const ( // drwxr-xr-x DefaultDirPerm = os.ModeDir | 0755 // -rw------- DefaultFilePerm = 0600 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type AcceptPart ¶
type AcceptPart struct {
// contains filtered or unexported fields
}
type App ¶
type Cookie ¶
type Cookie struct { Name string `json:"name"` Value string `json:"value"` Path string `json:"path"` Domain string `json:"domain"` Expires time.Time `json:"expires"` MaxAge int `json:"max_age"` Secure bool `json:"secure"` HttpOnly bool `json:"http_only"` SameSite string `json:"same_site"` SessionOnly bool `json:"session_only"` }
type Middleware ¶
type MiddlewareWrapper ¶
type MiddlewareWrapper struct { Path string Middleware Middleware }
MiddlewareWrapper wraps a Middleware with a certain path If the path is empty, the middleware will be applied globally to all requests If the path is set, the middleware will only be applied to matched requests
type Req ¶
type Req struct { LocalAddress string Method string Path string Body string Headers map[string]string Params map[string]string Queries map[string]string Cookies map[string]string *Ctx }
func (*Req) Accepts ¶
Checks if the specified types are accepted from the HTTP client TODO: Fix Canonicalization
func (*Req) AcceptsCharsets ¶
Checks if the specified types are accepted from the HTTP client
func (*Req) AcceptsEncodings ¶
func (*Req) AcceptsLanguages ¶
func (*Req) Fresh ¶
Return true when the response is still “fresh” in the client's cache. otherwise false is returned to indicate that the client cache is now stale and the full response should be sent. When a client sends the Cache-Control: no-cache request header to indicate an end-to-end reload request, this will return false to make handling these requests transparent. This logic is heavily inspired by the official gofiber source code, with some touches of mine: https://github.com/gofiber/fiber/blob/main/ctx.go
func (*Req) Host ¶
Return the base URL of the request derived from the `Host` HTTP header TODO: Should check the `X-Forwarded-Host` HTTP header also
func (*Req) ParseJson ¶
Parse the request body into the target struct Note that the target MUST be a pointer
type Res ¶
type Res struct { Socket net.Conn StatusCode int Headers map[string][]string ContentType string PrettyPrintJSON bool *Ctx }
func (*Res) ClearCookie ¶
Clear the specified client cookies If no keys are specified, all client cookies are cleared
type Router ¶
type Router struct { *App // contains filtered or unexported fields }