Documentation ¶
Index ¶
- Constants
- func Configure(cfg Map)
- func Go()
- func Ready()
- func Register(name string, value Any, overrides ...bool)
- func Route(name string, args ...Map) string
- func Routers(sites ...string) map[string]Router
- func SiteHosts(site string) []string
- func SiteUrl(name string, path string, options ...Map) string
- func StatusText(code int) string
- type Config
- type Connect
- type Context
- func (ctx *Context) Agent() string
- func (ctx *Context) Alert(res Res, urls ...string)
- func (ctx *Context) Answer(res Res, args ...Any)
- func (ctx *Context) Binary(bytes []byte, args ...string)
- func (ctx *Context) Buffer(rd io.ReadCloser, args ...string)
- func (ctx *Context) Charset(charsets ...string) string
- func (ctx *Context) Cookie(key string, vals ...Any) string
- func (ctx *Context) Denied(res Res)
- func (ctx *Context) Echo(res Res, args ...Any)
- func (ctx *Context) Error(res Res)
- func (ctx *Context) Failed(res Res)
- func (ctx *Context) File(file string, args ...string)
- func (ctx *Context) Found()
- 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) Html(html Any, args ...Any)
- func (ctx *Context) IP() 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) 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, kinds ...string) string
- func (ctx *Context) Next()
- func (ctx *Context) Proxy(url string)
- func (ctx *Context) Redirect(url string)
- func (ctx *Context) Route(name string, values ...Map)
- func (ctx *Context) Script(script string, args ...Any)
- func (ctx *Context) Show(res Res, urls ...string)
- func (ctx *Context) Sign(auth bool, payload Map, expires time.Duration, kinds ...string) string
- func (ctx *Context) Status(code int, texts ...string)
- func (ctx *Context) Text(text Any, args ...Any)
- func (ctx *Context) UserAgent() string
- func (ctx *Context) View(view string, args ...Any)
- func (ctx *Context) Xml(xml Any, args ...Any)
- type Cookie
- type Cross
- type Delegate
- type Driver
- type File
- type Filter
- type Find
- type Handler
- type Health
- type Helper
- type Info
- type Instance
- type Item
- type Module
- func (this *Module) Config(name string, config Config, override bool)
- func (this *Module) Configure(global Map)
- func (this *Module) Connect()
- func (module *Module) Driver(name string, driver Driver, override bool)
- func (this *Module) Filter(name string, config Filter, override bool)
- func (this *Module) Handler(name string, config Handler, override bool)
- func (this *Module) Helper(name string, config Helper, override bool)
- func (this *Module) Initialize()
- func (this *Module) Launch()
- func (this *Module) Register(name string, value Any, override bool)
- func (this *Module) Router(name string, config Router, override bool)
- func (module *Module) Routers(sites ...string) map[string]Router
- func (this *Module) Site(name string, site Site, override bool)
- func (this *Module) Sites(name string, site Sites, override bool)
- func (this *Module) Terminate()
- type RawBody
- type Router
- type Routing
- type Site
- type Sites
- type TOMLBuffer
- type TOMLBuilder
- type TOMLFile
Constants ¶
View Source
const ( NAME = "HTTP" WWW = "www" )
View Source
const ( StatusContinue = 100 // RFC 7231, 6.2.1 StatusSwitchingProtocols = 101 // RFC 7231, 6.2.2 StatusProcessing = 102 // RFC 2518, 10.1 StatusEarlyHints = 103 // RFC 8297 StatusOK = 200 // RFC 7231, 6.3.1 StatusCreated = 201 // RFC 7231, 6.3.2 StatusAccepted = 202 // RFC 7231, 6.3.3 StatusNonAuthoritativeInfo = 203 // RFC 7231, 6.3.4 StatusNoContent = 204 // RFC 7231, 6.3.5 StatusResetContent = 205 // RFC 7231, 6.3.6 StatusPartialContent = 206 // RFC 7233, 4.1 StatusMultiStatus = 207 // RFC 4918, 11.1 StatusAlreadyReported = 208 // RFC 5842, 7.1 StatusIMUsed = 226 // RFC 3229, 10.4.1 StatusMultipleChoices = 300 // RFC 7231, 6.4.1 StatusMovedPermanently = 301 // RFC 7231, 6.4.2 StatusFound = 302 // RFC 7231, 6.4.3 StatusSeeOther = 303 // RFC 7231, 6.4.4 StatusNotModified = 304 // RFC 7232, 4.1 StatusUseProxy = 305 // RFC 7231, 6.4.5 StatusTemporaryRedirect = 307 // RFC 7231, 6.4.7 StatusPermanentRedirect = 308 // RFC 7538, 3 StatusBadRequest = 400 // RFC 7231, 6.5.1 StatusPaymentRequired = 402 // RFC 7231, 6.5.2 StatusForbidden = 403 // RFC 7231, 6.5.3 StatusNotFound = 404 // RFC 7231, 6.5.4 StatusMethodNotAllowed = 405 // RFC 7231, 6.5.5 StatusNotAcceptable = 406 // RFC 7231, 6.5.6 StatusProxyAuthRequired = 407 // RFC 7235, 3.2 StatusRequestTimeout = 408 // RFC 7231, 6.5.7 StatusConflict = 409 // RFC 7231, 6.5.8 StatusGone = 410 // RFC 7231, 6.5.9 StatusLengthRequired = 411 // RFC 7231, 6.5.10 StatusPreconditionFailed = 412 // RFC 7232, 4.2 StatusRequestEntityTooLarge = 413 // RFC 7231, 6.5.11 StatusRequestURITooLong = 414 // RFC 7231, 6.5.12 StatusUnsupportedMediaType = 415 // RFC 7231, 6.5.13 StatusRequestedRangeNotSatisfiable = 416 // RFC 7233, 4.4 StatusExpectationFailed = 417 // RFC 7231, 6.5.14 StatusTeapot = 418 // RFC 7168, 2.3.3 StatusMisdirectedRequest = 421 // RFC 7540, 9.1.2 StatusUnprocessableEntity = 422 // RFC 4918, 11.2 StatusLocked = 423 // RFC 4918, 11.3 StatusFailedDependency = 424 // RFC 4918, 11.4 StatusTooEarly = 425 // RFC 8470, 5.2. StatusUpgradeRequired = 426 // RFC 7231, 6.5.15 StatusPreconditionRequired = 428 // RFC 6585, 3 StatusTooManyRequests = 429 // RFC 6585, 4 StatusRequestHeaderFieldsTooLarge = 431 // RFC 6585, 5 StatusInternalServerError = 500 // RFC 7231, 6.6.1 StatusNotImplemented = 501 // RFC 7231, 6.6.2 StatusBadGateway = 502 // RFC 7231, 6.6.3 StatusGatewayTimeout = 504 // RFC 7231, 6.6.5 StatusHTTPVersionNotSupported = 505 // RFC 7231, 6.6.6 StatusVariantAlsoNegotiates = 506 // RFC 2295, 8.1 StatusInsufficientStorage = 507 // RFC 4918, 11.5 StatusLoopDetected = 508 // RFC 5842, 7.2 StatusNotExtended = 510 // RFC 2774, 7 StatusNetworkAuthenticationRequired = 511 // RFC 6585, 6 )
HTTP status codes as registered with IANA. See: https://www.iana.org/assignments/http-status-codes/http-status-codes.xhtml
Variables ¶
This section is empty.
Functions ¶
func StatusText ¶
StatusText returns a text for the HTTP status code. It returns the empty string if the code is unknown.
Types ¶
type Config ¶
type Config struct { // Driver 驱动 Driver string // Port 监听端口 Port int // Host 绑定的IP,默认绑定所有IP Host string // CertFile SSL证书cert文件 CertFile string // Key SSL证书key文件 KeyFile string // Domain 主域,不是子域名,如 chefgo.org Domain string // Charset 默认字符集 // 默认值 utf-8 Charset string // Cookie 默认cookie名称 // 用于token或sessionid的浏览器cookie名 // 如果不为空,则表示,token写入cookie Cookie string // Token 是否自动生成TOKEN // 当cookie不为空,且token=true的时候,会自动生成空token Token bool // Expiry 下发token的有效期, // 默认使用token本身的有效期设置 Expiry time.Duration // Crypto 表示cookie是否加密 Crypto bool // MaxAge cookie的超时时间 // 0 表示不过时 MaxAge time.Duration // HttpOnly COOKIE设置是否httponly HttpOnly bool // Upload 上传文件临时目录 // 默认 os.TempDir() Upload string // Static 静态文件目录 // 默认 asset/statics Static string // 静态文件搜索的共享目录名 // 默认值 shared Shared string // Defaults 默认文件名 // 当访问静态文件时,如果目录的是目录,默认搜索的文件名 // 默认 index.html default.html Defaults []string // Validate 请求验证是否开启 // 开启的话,所有接口请求要验证后才能正常请求 Validate string // Format 请求验证时候的内容格式 Format string // Timeout 请求超时 Timeout time.Duration // Confuse api输出时候内容混淆 // 使用Codec定义,比如,text, string, rsa, aes 啥的 // 留空表示不混淆 Confuse string // Setting 设置 Setting Map }
type Connect ¶
type Connect interface { // Open 打开连接 Open() error // Health 运行状态 // 返回驱动的运行状态信息,用于监控 Health() (Health, error) //Close 关闭连接 Close() error // Accept 委托 Accept(Delegate) error // Register 注册路由 Register(name string, info Info) error // Start 启动HTTP Start() error // StartTLS 以TLS的方式启动HTTP StartTLS(certFile, keyFile string) error }
Connect 连接
type Context ¶
type Context struct { chef.Meta // 以下几个字段必须独立 // 要不然,Invoke的时候,会被修改掉 Name string Config Router Setting Map Site string Method string Host string Domain string Subdomain 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 Url httpUrl // contains filtered or unexported fields }
func (*Context) Echo ¶ added in v0.0.4
func (ctx *Context) Echo(res Res, args ...Any)
接口统一输出方法 args表示返回给客户端的data 也会从 ctx.Data 先读取数据,然后使用args中的覆盖
type Delegate ¶
type Delegate interface { // Serve 响应请求 Serve(name string, params Map, res http.ResponseWriter, req *http.Request) }
type File ¶
type File struct { // Checksum 使用 sha256算法 Checksum string `json:"checksum"` // Filename 是文件的原始文件名 Filename string `json:"filename"` // Extension 扩展名,不包括点(.) Extension string `json:"extension"` // Mimetype 是文件的MIMEType Mimetype string `json:"mimetype"` // Length 文件大小,单位:字节 Length int64 `json:"length"` // Tempfile 临时文件路径 Tempfile string `json:"tempfile"` }
type Filter ¶
type Filter struct { Name string `json:"name"` Text string `json:"text"` Serve ctxFunc `json:"-"` Request ctxFunc `json:"-"` Execute ctxFunc `json:"-"` Response ctxFunc `json:"-"` // contains filtered or unexported fields }
Filter 拦截器
type Handler ¶
type Handler struct { Name string `json:"name"` Text string `json:"text"` Found ctxFunc `json:"-"` Error ctxFunc `json:"-"` Failed ctxFunc `json:"-"` Denied ctxFunc `json:"-"` // contains filtered or unexported fields }
Handler 处理器
type Module ¶
type Module struct {
// contains filtered or unexported fields
}
func (*Module) Initialize ¶
func (this *Module) Initialize()
type Router ¶
type Router struct { Method string Uri string `json:"uri"` Uris []string `json:"uris"` Name string `json:"name"` Text string `json:"text"` Nullable bool `json:"-"` Socket bool `json:"socket"` //预留,为后面的websocket模块 Args Vars `json:"args"` Data Vars `json:"data"` Setting Map `json:"-"` Find Find `json:"find"` Coding bool `json:"-"` Routing Routing `json:"routing"` Actions []ctxFunc `json:"-"` Action ctxFunc `json:"-"` Sign bool `json:"Sign"` Auth bool `json:"auth"` Kind string `json:"kind"` // 路由单独可定义的处理器 Found ctxFunc `json:"-"` Error ctxFunc `json:"-"` Failed ctxFunc `json:"-"` Denied ctxFunc `json:"-"` // contains filtered or unexported fields }
type Site ¶
type Site struct { // Name 名称 Name string // Ssl 是否开启SSL Ssl bool // Domain 主域 // 为空则从 http.Config 中继承 Domain string // Hosts 绑定的域名列表 // 如果为空,为自动设置为当前站点的 key + Domain // 如果Hosts中带主域名,比如,只设置为 ["aaa", "bbb"] // 系统会自动将 aaa,bbb 加上 主域名,如 aaa.chefgo.org Hosts []string // Charset 字符集 // 为空则从 http.Config 中继承,默认 utf-8 Charset string // Cookie 默认cookie名称 // 用于token或sessionid的浏览器cookie名 Cookie string // Token 是否自动生成 Token bool // Expiry 下发token的有效期, // 默认使用token本身的有效期设置 Expiry time.Duration // Crypto 表示cookie是否加密 Crypto bool // MaxAge cookie的超时时间 // 0 表示不过时 MaxAge time.Duration // HttpOnly COOKIE设置是否httponly HttpOnly bool // Validate 请求验证是否开启 // 开启的话,所有接口请求要验证后才能正常请求 Validate string // Format 请求验证时候的内容格式 Format string // Timeout 请求超时 Timeout time.Duration // Confuse api输出时候内容混淆 // 使用Codec定义,比如,text, string, rsa, aes 啥的 // 留空表示不混淆 Confuse string // Setting 设置 Setting Map }
type TOMLBuffer ¶
type TOMLBuffer struct {
// contains filtered or unexported fields
}
func (*TOMLBuffer) Close ¶
func (buf *TOMLBuffer) Close() error
type TOMLBuilder ¶
type TOMLBuilder struct {
// contains filtered or unexported fields
}
func NewTOMLBuilder ¶
func NewTOMLBuilder() *TOMLBuilder
func (*TOMLBuilder) Append ¶
func (this *TOMLBuilder) Append(key string, vals ...string)
func (*TOMLBuilder) Build ¶
func (this *TOMLBuilder) Build() string
func (*TOMLBuilder) Files ¶
func (this *TOMLBuilder) Files() map[string][]TOMLFile
func (*TOMLBuilder) Forms ¶
func (this *TOMLBuilder) Forms() map[string][]string
func (*TOMLBuilder) Store ¶
func (this *TOMLBuilder) Store(key, name, mime string, buf io.ReadSeekCloser)
Click to show internal directories.
Click to hide internal directories.