Documentation ¶
Index ¶
- Constants
- Variables
- func Logger() logger.AbstractLogger
- func Make(service interface{}, params ...interface{}) interface{}
- func RegisterCodeHandler(status int, handler Handler)
- func RegisterOnInterrupt(handler func())
- func RegisterViewEngine(engine render.AbstractRenderer)
- func SetControllerDefaultAction(str string)
- type AbstractReadonlyConfiguration
- type AbstractRouter
- type Application
- type Configuration
- func (c *Configuration) GetAutoParseControllerResult() bool
- func (c *Configuration) GetCompressGzip() bool
- func (c *Configuration) GetCookieTranscoder() sessions.AbstractCookieTranscoder
- func (c *Configuration) GetDefaultResponseType() string
- func (c *Configuration) GetMaxMultipartMemory() int64
- func (c *Configuration) GetServerName() string
- func (c *Configuration) GetTimeout() TimeoutConf
- func (c *Configuration) GetUseCookie() bool
- type Configurator
- func WithAutoParseControllerResult(auto bool) Configurator
- func WithCompressGzip(enable bool) Configurator
- func WithCookie(open bool) Configurator
- func WithCookieTranscoder(transcoder sessions.AbstractCookieTranscoder) Configurator
- func WithDefaultResponseType(responseType string) Configurator
- func WithGracefulShutdown() Configurator
- func WithMaxMultipartMemory(mem int64) Configurator
- func WithServerName(srvName string) Configurator
- func WithTimeout(conf TimeoutConf) Configurator
- func WithTlsFile(key, secret string) Configurator
- func WithoutStartupLog(hide bool) Configurator
- type Context
- func (c *Context) Abort(statusCode int, msg ...string)
- func (i Context) Add(key string, value interface{})
- func (i Context) All() map[string]interface{}
- func (c *Context) BindForm(rev interface{}) error
- func (c *Context) BindJSON(rev interface{}) error
- func (i Context) Clear()
- func (c *Context) ClientIP() string
- func (c *Context) Clone()
- func (i Context) Del(keys ...string)
- func (i Context) DelExcept(keys ...string)
- func (i Context) Files(key string) (*multipart.FileHeader, error)
- func (i Context) Get(key string) interface{}
- func (i Context) GetBool(key string, defaultVal ...bool) (val bool, err error)
- func (i Context) GetBytes(key string) ([]byte, error)
- func (c *Context) GetCookie(name string) string
- func (i Context) GetDeep(key string) (*fastjson.Value, error)
- func (i Context) GetFloat64(key string, defaultVal ...float64) (val float64, err error)
- func (i Context) GetForm() *multipart.Form
- func (i Context) GetFormStrings(key string) []string
- func (i Context) GetInt(key string, defaultVal ...int) (val int, err error)
- func (i Context) GetInt64(key string, defaultVal ...int64) (val int64, err error)
- func (i Context) GetString(key string, defaultVal ...string) (val string, err error)
- func (c *Context) Handle()
- func (c *Context) HandlerName() string
- func (i Context) Has(key string) bool
- func (c *Context) Header(key string) string
- func (c *Context) Input() *input
- func (c *Context) IsAjax() bool
- func (i Context) IsJson() bool
- func (c *Context) IsStopped() bool
- func (i Context) LastErr() error
- func (c *Context) Logger() logger.AbstractLogger
- func (c *Context) LoggerEntity() *logger.LogEntity
- func (c *Context) Next()
- func (i Context) Only(keys ...string) map[string]interface{}
- func (c *Context) Params() Params
- func (c *Context) Path() string
- func (i Context) PostForm() map[string][]string
- func (c *Context) Redirect(url string, statusHeader ...int)
- func (c *Context) RemoveCookie(name string)
- func (c *Context) Render() *Render
- func (i Context) ResetFromContext()
- func (c *Context) SendFile(filepath string)
- func (c *Context) Session(sessIns ...sessions.AbstractSession) sessions.AbstractSession
- func (c *Context) Set(key string, value interface{})
- func (c *Context) SetCookie(name string, value string, maxAge int)
- func (c *Context) SetStatus(statusCode int)
- func (c *Context) Stop()
- func (c *Context) Value(key string) interface{}
- func (c *Context) Write(data []byte) error
- func (c *Context) WriteHTMLBytes(data []byte) error
- func (c *Context) WriteJSON(v interface{}) error
- func (c *Context) WriteString(str string) error
- type Controller
- func (c *Controller) Ctx() *Context
- func (c *Controller) Input() *input
- func (c *Controller) Logger() logger.AbstractLogger
- func (c *Controller) Render() *Render
- func (c *Controller) Session() sessions.AbstractSession
- func (c *Controller) View(name string)
- func (c *Controller) ViewData(key string, val interface{})
- type H
- type Handler
- type IController
- type IRegisterHandler
- type IRouterWrapper
- type Params
- func (c Params) Get(key string) string
- func (c Params) GetBool(key string, defaultVal bool) bool
- func (c Params) GetDefault(key, defaultVal string) string
- func (c Params) GetFloat64(key string, defaultVal ...float64) (val float64, err error)
- func (c Params) GetInt(key string, defaultVal ...int) (val int, err error)
- func (c Params) GetInt64(key string, defaultVal ...int64) (val int64, err error)
- func (c Params) Set(key, value string)
- type Render
- func (c *Render) Bytes(v []byte) error
- func (c *Render) ContentType(typ string)
- func (c *Render) GetEngine(ext string) render.AbstractRenderer
- func (c *Render) GetViewData() map[string]interface{}
- func (c *Render) HTML(viewPath string)
- func (c *Render) JSON(v interface{}) error
- func (c *Render) JSONP(callback string, v interface{}) error
- func (c *Render) Text(v string) error
- func (c *Render) ViewData(key string, val interface{})
- func (c *Render) XML(v interface{}) error
- type RouteEntry
- type Router
- func (r *Router) ANY(path string, handle Handler, mws ...Handler)
- func (r *Router) AddRoute(method, path string, handle Handler, mws ...Handler)
- func (r *Router) DELETE(path string, handle Handler, mws ...Handler)
- func (r *Router) DumpRouteTable()
- func (r *Router) Favicon(file interface{})
- func (r *Router) GET(path string, handle Handler, mws ...Handler)
- func (r *Router) Group(prefix string, middleWares ...Handler) *Router
- func (r *Router) HEAD(path string, handle Handler, mws ...Handler)
- func (r *Router) Handle(c IController, prefix ...string) *Router
- func (r *Router) POST(path string, handle Handler, mws ...Handler)
- func (r *Router) PUT(path string, handle Handler, mws ...Handler)
- func (r *Router) Static(urlPath, dir string, stripSlashes ...int)
- func (r *Router) StaticFS(urlPath string, f fs.FS, filePrefix string, indexfile ...string)
- func (r *Router) StaticFile(path, file string, mws ...Handler)
- func (r *Router) Subdomain(subdomain string) *Router
- func (r *Router) Use(middleWares ...Handler)
- type RouterTableRow
- type ServerHandler
- type TimeoutConf
Constants ¶
View Source
const ( HeaderContentType = fasthttp.HeaderContentType ContentTypeJSON = "application/json; charset=utf-8" ContentTypeHTML = "text/html; charset=utf-8" ContentTypeText = "text/plain; charset=utf-8" ContentTypeXML = "text/xml; charset=utf-8" )
View Source
const FilePathParam = "filepath"
View Source
const GoRawBody = "pine://input"
View Source
const Version = "dev 0.1.0"
Variables ¶
View Source
var (
DefaultErrTemplate = template.Must(template.New("ErrTemplate").Parse(`<!DOCTYPE html><html><head><meta charset="UTF-8"><meta name="viewport"content="width=device-width,initial-scale=1"><title>{{.Code}}|{{.Message}}</title><style type="text/css">body{font-family:-apple-system,BlinkMacSystemFont,"Segoe UI","Roboto","Oxygen","Ubuntu","Cantarell","Fira Sans","Droid Sans","Helvetica Neue",sans-serif}h1{line-height:1;color:#252427;display:inline-block;border-right:1px solid rgba(0,0,0,.3);margin:0;margin-right:20px;padding:10px 23px 10px 0;font-size:24px;font-weight:500;vertical-align:top}h2{margin:100px 0 0;font-weight:600;letter-spacing:0.1em;color:#A299AC;text-transform:uppercase}</style></head><body><div style="color:#000;background:#fff;font-family:-apple-system, BlinkMacSystemFont, Roboto, 'Segoe UI', 'Fira Sans', Avenir, 'Helvetica Neue', 'Lucida Grande', sans-serif;height:100vh;text-align:center;display:flex;flex-direction:column;align-items:center;justify-content:center"><div><style>body{margin:0}</style><h1>{{.Code}}</h1><div style="display:inline-block;text-align:left;line-height:49px;height:49px;vertical-align:middle"><h2 style="font-size:14px;font-weight:normal;line-height:inherit;margin:0;padding:0">{{.Message}}</h2></div></div></div></body></html>`))
)
View Source
var EmptyBytes = []byte("")
View Source
var ErrKeyNotFound = errors.New("key not found")
Functions ¶
func RegisterCodeHandler ¶ added in v0.0.6
func RegisterOnInterrupt ¶
func RegisterOnInterrupt(handler func())
func RegisterViewEngine ¶
func RegisterViewEngine(engine render.AbstractRenderer)
func SetControllerDefaultAction ¶ added in v0.0.6
func SetControllerDefaultAction(str string)
Types ¶
type AbstractReadonlyConfiguration ¶
type AbstractReadonlyConfiguration interface { GetServerName() string GetUseCookie() bool GetMaxMultipartMemory() int64 GetAutoParseControllerResult() bool GetCookieTranscoder() sessions.AbstractCookieTranscoder GetDefaultResponseType() string GetCompressGzip() bool GetTimeout() TimeoutConf }
type AbstractRouter ¶
type AbstractRouter interface { AddRoute(method, path string, handle Handler, mws ...Handler) ANY(path string, handle Handler, mws ...Handler) GET(path string, handle Handler, mws ...Handler) POST(path string, handle Handler, mws ...Handler) HEAD(path string, handle Handler, mws ...Handler) PUT(path string, handle Handler, mws ...Handler) DELETE(path string, handle Handler, mws ...Handler) StaticFile(string, string, ...Handler) Static(string, string, ...int) }
type Application ¶
type Application struct { *Router DI di.AbstractBuilder ReadonlyConfiguration AbstractReadonlyConfiguration // contains filtered or unexported fields }
func New ¶
func New() *Application
func (*Application) Close ¶ added in v0.0.6
func (a *Application) Close()
func (*Application) NotAllowMethod ¶ added in v0.0.6
func (a *Application) NotAllowMethod(handler Handler)
func (*Application) Run ¶
func (a *Application) Run(srv ServerHandler, opts ...Configurator)
func (*Application) SetNotFound ¶
func (a *Application) SetNotFound(handler Handler)
func (*Application) SetRecoverHandler ¶
func (a *Application) SetRecoverHandler(handler Handler)
type Configuration ¶
type Configuration struct { CookieTranscoder sessions.AbstractCookieTranscoder // contains filtered or unexported fields }
func (*Configuration) GetAutoParseControllerResult ¶
func (c *Configuration) GetAutoParseControllerResult() bool
func (*Configuration) GetCompressGzip ¶ added in v0.0.6
func (c *Configuration) GetCompressGzip() bool
func (*Configuration) GetCookieTranscoder ¶
func (c *Configuration) GetCookieTranscoder() sessions.AbstractCookieTranscoder
func (*Configuration) GetDefaultResponseType ¶ added in v0.0.6
func (c *Configuration) GetDefaultResponseType() string
func (*Configuration) GetMaxMultipartMemory ¶
func (c *Configuration) GetMaxMultipartMemory() int64
func (*Configuration) GetServerName ¶
func (c *Configuration) GetServerName() string
func (*Configuration) GetTimeout ¶ added in v0.0.6
func (c *Configuration) GetTimeout() TimeoutConf
func (*Configuration) GetUseCookie ¶ added in v0.0.4
func (c *Configuration) GetUseCookie() bool
type Configurator ¶
type Configurator func(o *Configuration)
func WithAutoParseControllerResult ¶
func WithAutoParseControllerResult(auto bool) Configurator
func WithCompressGzip ¶ added in v0.0.6
func WithCompressGzip(enable bool) Configurator
func WithCookie ¶ added in v0.0.4
func WithCookie(open bool) Configurator
func WithCookieTranscoder ¶
func WithCookieTranscoder(transcoder sessions.AbstractCookieTranscoder) Configurator
func WithDefaultResponseType ¶ added in v0.0.6
func WithDefaultResponseType(responseType string) Configurator
func WithGracefulShutdown ¶ added in v0.0.6
func WithGracefulShutdown() Configurator
func WithMaxMultipartMemory ¶
func WithMaxMultipartMemory(mem int64) Configurator
func WithServerName ¶
func WithServerName(srvName string) Configurator
func WithTimeout ¶ added in v0.0.6
func WithTimeout(conf TimeoutConf) Configurator
func WithTlsFile ¶ added in v0.0.6
func WithTlsFile(key, secret string) Configurator
func WithoutStartupLog ¶
func WithoutStartupLog(hide bool) Configurator
type Context ¶
type Context struct { *fasthttp.RequestCtx // Temporary recording error information Msg string // contains filtered or unexported fields }
func (Context) DelExcept ¶ added in v0.0.6
func (i Context) DelExcept(keys ...string)
DelExcept 删除指定keys之外的数据
func (Context) GetFloat64 ¶
func (Context) GetFormStrings ¶ added in v0.0.6
func (*Context) HandlerName ¶ added in v0.0.6
func (*Context) Logger ¶
func (c *Context) Logger() logger.AbstractLogger
func (*Context) LoggerEntity ¶ added in v0.0.6
func (*Context) RemoveCookie ¶
func (Context) ResetFromContext ¶ added in v0.0.6
func (i Context) ResetFromContext()
func (*Context) Session ¶
func (c *Context) Session(sessIns ...sessions.AbstractSession) sessions.AbstractSession
func (*Context) WriteHTMLBytes ¶ added in v0.0.5
func (*Context) WriteString ¶
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func (*Controller) Ctx ¶
func (c *Controller) Ctx() *Context
func (*Controller) Input ¶ added in v0.0.6
func (c *Controller) Input() *input
func (*Controller) Logger ¶
func (c *Controller) Logger() logger.AbstractLogger
func (*Controller) Render ¶
func (c *Controller) Render() *Render
func (*Controller) Session ¶
func (c *Controller) Session() sessions.AbstractSession
func (*Controller) View ¶
func (c *Controller) View(name string)
func (*Controller) ViewData ¶
func (c *Controller) ViewData(key string, val interface{})
type IController ¶
type IController interface { Ctx() *Context Input() *input Render() *Render Logger() logger.AbstractLogger Session() sessions.AbstractSession }
type IRegisterHandler ¶
type IRegisterHandler interface {
RegisterRoute(IRouterWrapper)
}
type IRouterWrapper ¶
type IRouterWrapper interface { ANY(path string, handle string, mws ...Handler) GET(path string, handle string, mws ...Handler) POST(path string, handle string, mws ...Handler) PUT(path string, handle string, mws ...Handler) HEAD(path string, handle string, mws ...Handler) DELETE(path string, handle string, mws ...Handler) // contains filtered or unexported methods }
type Params ¶ added in v0.0.6
func (Params) GetDefault ¶ added in v0.0.6
func (Params) GetFloat64 ¶ added in v0.0.6
type Render ¶
type Render struct {
// contains filtered or unexported fields
}
func (*Render) ContentType ¶
func (*Render) GetViewData ¶
type RouteEntry ¶
type Router ¶
type Router struct {
// contains filtered or unexported fields
}
func (*Router) DumpRouteTable ¶ added in v0.0.6
func (r *Router) DumpRouteTable()
func (*Router) StaticFile ¶
type RouterTableRow ¶ added in v0.0.6
type ServerHandler ¶
type ServerHandler func(*Application) error
func Addr ¶
func Addr(addr string) ServerHandler
Source Files ¶
Click to show internal directories.
Click to hide internal directories.