Documentation
¶
Index ¶
- Constants
- func RouteUri(name string, values ...Map) string
- func RouteUrl(name string, values ...Map) string
- func SetFS(fsys fs.FS)
- func SiteUrl(name, path string, options ...Map) string
- func StatusText(code int) string
- type Config
- type Configs
- type Connection
- type Context
- func (ctx *Context) Agent() string
- func (ctx *Context) Answer(res Res, args ...Any)
- func (ctx *Context) Binary(bytes []byte, args ...string)
- func (ctx *Context) Charset(charsets ...string) string
- func (ctx *Context) Cookie(key string, vals ...Any) string
- func (ctx *Context) Deny(args ...Res)
- func (ctx *Context) Error(args ...Res)
- func (ctx *Context) Fail(args ...Res)
- func (ctx *Context) File(file string, args ...string)
- func (ctx *Context) Goto(url string)
- func (ctx *Context) HTML(html Any, args ...Any)
- func (ctx *Context) Header(key string, vals ...string) string
- func (ctx *Context) IP() string
- func (ctx *Context) JSON(json Any, args ...Any)
- func (ctx *Context) JSONP(callback string, json Any, args ...Any)
- func (ctx *Context) NewSign(auth bool, payload Map, expires ...time.Duration) string
- func (ctx *Context) NewSignAt(auth bool, payload Map, begin time.Time, expires ...time.Duration) string
- func (ctx *Context) Next()
- func (ctx *Context) NotFound()
- func (ctx *Context) Proxy(target string)
- func (ctx *Context) Redirect(url string)
- func (ctx *Context) RouteUri(name string, values ...Map) string
- func (ctx *Context) RouteUrl(name string, values ...Map) string
- func (ctx *Context) Sign(auth bool, payload Map, expires ...time.Duration) string
- func (ctx *Context) SignAt(auth bool, payload Map, begin time.Time, expires ...time.Duration) string
- func (ctx *Context) SiteUrl(name, path string, options ...Map) string
- func (ctx *Context) Status(code int, texts ...string)
- func (ctx *Context) Stream(buffer io.ReadCloser, size int64, args ...string)
- func (ctx *Context) Text(text Any, args ...Any)
- func (ctx *Context) Unauth(args ...Res)
- func (ctx *Context) Unsign(args ...Res)
- func (ctx *Context) Upgrade(spaces ...string) error
- func (ctx *Context) View(view string, args ...Any)
- type Cookie
- type Cross
- type Delegate
- type Driver
- type File
- type Filter
- type Handler
- type Info
- type Instance
- type Loader
- type Loading
- type Module
- func (m *Module) Close()
- func (m *Module) Config(global Map)
- func (m *Module) Open()
- func (m *Module) Register(name string, value Any)
- func (m *Module) RegisterConfig(name string, config Config)
- func (m *Module) RegisterConfigs(configs Configs)
- func (m *Module) RegisterDriver(name string, driver Driver)
- func (m *Module) RegisterFilter(name string, config Filter)
- func (m *Module) RegisterHandler(name string, config Handler)
- func (m *Module) RegisterRouter(name string, config Router)
- func (m *Module) RegisterRouters(prefix string, routers Routers)
- func (m *Module) Serve(name string, params Map, res http.ResponseWriter, req *http.Request)
- func (m *Module) Setup()
- func (m *Module) Start()
- func (m *Module) Stop()
- type Router
- type Routers
- type Routing
- type Site
- type Sites
- type Socket
Constants ¶
const ( UTF8 = "utf-8" DEFAULT = "default" )
const ( StatusContinue = http.StatusContinue StatusSwitchingProtocols = http.StatusSwitchingProtocols StatusProcessing = http.StatusProcessing StatusEarlyHints = http.StatusEarlyHints StatusOK = http.StatusOK StatusCreated = http.StatusCreated StatusAccepted = http.StatusAccepted StatusNonAuthoritativeInfo = http.StatusNonAuthoritativeInfo StatusNoContent = http.StatusNoContent StatusResetContent = http.StatusResetContent StatusPartialContent = http.StatusPartialContent StatusMultipleChoices = http.StatusMultipleChoices StatusMovedPermanently = http.StatusMovedPermanently StatusFound = http.StatusFound StatusSeeOther = http.StatusSeeOther StatusNotModified = http.StatusNotModified StatusUseProxy = http.StatusUseProxy StatusTemporaryRedirect = http.StatusTemporaryRedirect StatusPermanentRedirect = http.StatusPermanentRedirect StatusBadRequest = http.StatusBadRequest StatusPaymentRequired = http.StatusPaymentRequired StatusForbidden = http.StatusForbidden StatusNotFound = http.StatusNotFound StatusMethodNotAllowed = http.StatusMethodNotAllowed StatusNotAcceptable = http.StatusNotAcceptable StatusProxyAuthRequired = http.StatusProxyAuthRequired StatusRequestTimeout = http.StatusRequestTimeout StatusConflict = http.StatusConflict StatusGone = http.StatusGone StatusLengthRequired = http.StatusLengthRequired StatusPreconditionFailed = http.StatusPreconditionFailed StatusRequestEntityTooLarge = http.StatusRequestEntityTooLarge StatusRequestURITooLong = http.StatusRequestURITooLong StatusUnsupportedMediaType = http.StatusUnsupportedMediaType StatusRequestedRangeNotSatisfiable = http.StatusRequestedRangeNotSatisfiable StatusExpectationFailed = http.StatusExpectationFailed StatusTeapot = http.StatusTeapot StatusMisdirectedRequest = http.StatusMisdirectedRequest StatusUnprocessableEntity = http.StatusUnprocessableEntity StatusLocked = http.StatusLocked StatusFailedDependency = http.StatusFailedDependency StatusTooEarly = http.StatusTooEarly StatusUpgradeRequired = http.StatusUpgradeRequired StatusPreconditionRequired = http.StatusPreconditionRequired StatusTooManyRequests = http.StatusTooManyRequests StatusRequestHeaderFieldsTooLarge = http.StatusRequestHeaderFieldsTooLarge StatusInternalServerError = http.StatusInternalServerError StatusNotImplemented = http.StatusNotImplemented StatusBadGateway = http.StatusBadGateway StatusGatewayTimeout = http.StatusGatewayTimeout StatusHTTPVersionNotSupported = http.StatusHTTPVersionNotSupported StatusVariantAlsoNegotiates = http.StatusVariantAlsoNegotiates StatusInsufficientStorage = http.StatusInsufficientStorage StatusLoopDetected = http.StatusLoopDetected StatusNotExtended = http.StatusNotExtended StatusNetworkAuthenticationRequired = http.StatusNetworkAuthenticationRequired )
Variables ¶
This section is empty.
Functions ¶
func StatusText ¶
Types ¶
type Config ¶
type Config struct {
Driver string
Port int
Host string
CertFile string
KeyFile string
Charset string
Cookie string
Token bool
Expire time.Duration
Crypto bool
MaxAge time.Duration
HttpOnly bool
// AnswerDataEncode toggles ctx.Answer(data) payload encoding.
AnswerDataEncode bool
// AnswerDataCodec is codec name used by infra.Mapping Var.Encode.
AnswerDataCodec string
Upload string
Static string
Defaults []string
Domain string
Domains []string
Alias string
Aliases []string
Setting Map
// contains filtered or unexported fields
}
type Connection ¶
type Connection interface {
Open() error
Close() error
Register(name string, info Info, hosts []string) error
Upgrade(res http.ResponseWriter, req *http.Request) (Socket, error)
Start() error
StartTLS(certFile, keyFile string) error
}
Connection defines web connection interface.
type Context ¶
type Context struct {
*infra.Meta
Name string
Config Router
Setting Map
Method string
Host string
Site string
Domain string
RootDomain string
Path string
Uri string
Ajax bool
Params Map
Query Map
Form Map
Upload Map
Value Map
Args Map
Locals Map
Code int
Type string
Data Map
Body Any
// contains filtered or unexported fields
}
func (*Context) Answer ¶ added in v0.11.1
func (ctx *Context) Answer(res Res, args ...Any)
Answer outputs API response.
func (*Context) NewSign ¶ added in v0.9.0
NewSign issues token with new token id and marks cookie issuance. expires is optional duration, begin defaults to current time.
func (*Context) NewSignAt ¶ added in v0.9.0
func (ctx *Context) NewSignAt(auth bool, payload Map, begin time.Time, expires ...time.Duration) string
NewSignAt issues token with new token id and custom begin time. expires is optional duration.
func (*Context) Sign ¶ added in v0.9.0
Sign issues token and marks cookie issuance. expires is optional duration, begin defaults to current time.
func (*Context) SignAt ¶ added in v0.9.0
func (ctx *Context) SignAt(auth bool, payload Map, begin time.Time, expires ...time.Duration) string
SignAt issues token with custom begin time and marks cookie issuance. expires is optional duration.
type Delegate ¶
type Delegate interface {
Serve(name string, params Map, res http.ResponseWriter, req *http.Request)
}
Delegate handles web requests.
type Driver ¶
type Driver interface {
Connect(*Instance) (Connection, error)
}
Driver defines web driver interface.
type File ¶
type File struct {
Checksum string `json:"checksum"`
Filename string `json:"filename"`
Extension string `json:"extension"`
Mimetype string `json:"mimetype"`
Length int64 `json:"length"`
Tempfile string `json:"tempfile"`
}
File represents uploaded file info.
type Filter ¶
type Filter struct {
Name string `json:"name"`
Desc string `json:"desc"`
Serve ctxFunc `json:"-"`
Request ctxFunc `json:"-"`
Execute ctxFunc `json:"-"`
Response ctxFunc `json:"-"`
}
Filter defines HTTP filter/interceptor.
type Handler ¶
type Handler struct {
Name string `json:"name"`
Desc string `json:"desc"`
NotFound ctxFunc `json:"-"`
Error ctxFunc `json:"-"`
Failed ctxFunc `json:"-"`
Unsigned ctxFunc `json:"-"`
Unauthed ctxFunc `json:"-"`
Denied ctxFunc `json:"-"`
}
Handler defines HTTP handler for errors.
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) RegisterConfig ¶
RegisterConfig registers web config for a named site.
func (*Module) RegisterConfigs ¶
RegisterConfigs registers multiple configs.
func (*Module) RegisterDriver ¶
RegisterDriver registers a web driver.
func (*Module) RegisterFilter ¶
RegisterFilter registers a web filter.
func (*Module) RegisterHandler ¶
RegisterHandler registers a web handler.
func (*Module) RegisterRouter ¶
RegisterRouter registers a web router.
func (*Module) RegisterRouters ¶
RegisterRouters registers multiple routers.
type Router ¶
type Router struct {
Uri string `json:"uri"`
Uris []string `json:"uris"`
Key string `json:"-"`
Name string `json:"name"`
Desc string `json:"desc"`
Nullable bool `json:"-"`
Args Vars `json:"args"`
Data Vars `json:"data"`
Setting Map `json:"-"`
Loading Loading `json:"loading"`
Routing Routing `json:"routing"`
Actions []ctxFunc `json:"-"`
Action ctxFunc `json:"-"`
Sign bool `json:"sign"`
Auth bool `json:"auth"`
NotFound ctxFunc `json:"-"`
Error ctxFunc `json:"-"`
Failed ctxFunc `json:"-"`
Unsigned ctxFunc `json:"-"`
Unauthed ctxFunc `json:"-"`
Denied ctxFunc `json:"-"`
// contains filtered or unexported fields
}
Router defines HTTP route.