Documentation
¶
Index ¶
- Constants
- Variables
- func Logger() logger.AbstractLogger
- func Make(service interface{}, params ...interface{}) interface{}
- func RegisterErrorCodeHandler(status int, handler Handler)
- func RegisterOnInterrupt(handler func())
- func RegisterViewEngine(engine render.AbstractRenderer)
- type AbstractReadonlyConfiguration
- type AbstractRouter
- type Application
- type Configuration
- func (c *Configuration) GetAutoParseControllerResult() bool
- func (c *Configuration) GetAutoParseForm() bool
- func (c *Configuration) GetCharset() string
- func (c *Configuration) GetCookieTranscoder() cookie_transcoder.AbstractCookieTranscoder
- func (c *Configuration) GetMaxMultipartMemory() int64
- func (c *Configuration) GetServerName() string
- type Configurator
- func WithAutoParseControllerResult(auto bool) Configurator
- func WithAutoParseForm(autoParseForm bool) Configurator
- func WithCharset(charset string) Configurator
- func WithCookieTranscoder(transcoder cookie_transcoder.AbstractCookieTranscoder) Configurator
- func WithMaxMultipartMemory(mem int64) Configurator
- func WithServerName(srvName string) Configurator
- func WithoutStartupLog(hide bool) Configurator
- type Context
- func (c *Context) Abort(statusCode int, msg ...string)
- func (c *Context) BindForm(rev interface{}) error
- func (c *Context) BindJSON(rev interface{}) error
- func (c *Context) ClientIP() string
- func (c *Context) ExistsCookie(name string) bool
- func (c *Context) Files(key string) (multipart.File, *multipart.FileHeader, error)
- func (c *Context) FormValue(key string) string
- func (c *Context) GetBody() ([]byte, error)
- func (c *Context) GetBool(key string, defaultVal ...bool) (val bool, err error)
- func (c *Context) GetCookie(name string) string
- func (c *Context) GetData() map[string][]string
- func (c *Context) GetFloat64(key string, defaultVal ...float64) (val float64, err error)
- func (c *Context) GetInt(key string, defaultVal ...int) (val int, err error)
- func (c *Context) GetInt64(key string, defaultVal ...int64) (val int64, err error)
- func (c *Context) GetString(key string, defaultVal ...string) string
- func (c *Context) GetStrings(key string) (val []string)
- func (c *Context) Handle()
- func (c *Context) Header(key string) string
- func (c *Context) IsAjax() bool
- func (c *Context) IsGet() bool
- func (c *Context) IsPost() bool
- func (c *Context) IsStopped() bool
- func (c *Context) Logger() logger.AbstractLogger
- func (c *Context) Next()
- func (c *Context) Params() params
- func (c *Context) PostData() map[string][]string
- func (c *Context) PostFloat64(key string, defaultVal ...float64) (val float64, err error)
- func (c *Context) PostInt(key string, defaultVal ...int) (val int, err error)
- func (c *Context) PostInt64(key string, defaultVal ...int64) (val int64, err error)
- func (c *Context) PostString(key string, defaultVal ...string) string
- func (c *Context) PostStrings(key string) (val []string, ok bool)
- func (c *Context) PostValue(key string) string
- func (c *Context) Redirect(url string, statusHeader ...int)
- func (c *Context) RemoveCookie(name string)
- func (c *Context) Render() *Render
- func (c *Context) Request() *http.Request
- func (c *Context) SendFile(filepath string)
- func (c *Context) Session() 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) URLParam(key string) string
- func (c *Context) URLParamInt(key string) (int, error)
- func (c *Context) URLParamInt64(key string) (int64, error)
- func (c *Context) Value(key string) interface{}
- func (c *Context) WriteString(str string) error
- func (c *Context) Writer(writers ...http.ResponseWriter) http.ResponseWriter
- type Controller
- func (c *Controller) Cookie() *sessions.Cookie
- func (c *Controller) Ctx() *Context
- func (c *Controller) Logger() logger.AbstractLogger
- func (c *Controller) Param() params
- 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 Pool
- 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) 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) *Router
- func (r *Router) OPTIONS(path string, handle Handler, mws ...Handler)
- 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)
- func (r *Router) StaticFile(path, file string, mws ...Handler)
- func (r *Router) Subdomain(subdomain string) *Router
- func (r *Router) Use(middleWares ...Handler)
- type ServerHandler
Constants ¶
View Source
const ControllerSuffix = "Controller"
View Source
const Version = "dev 0.2.1"
Variables ¶
View Source
var (
DefaultErrTemplate = template.Must(template.New("ErrTemplate").Parse(`<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1" />
<title>{{.Code}} {{ .Message }}</title>
<style>
html {-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}
html, body {
margin: 0;
background-color: #fff;
color: #636b6f;
font-family: 'Open Sans', sans-serif;
font-weight: 100;
height: 80vh;
}
.container {
align-items: center;
display: flex;
justify-content: center;
position: relative;
height: 85vh;
}
.content {
text-align: center;
}
.title {
font-size: 36px;
font-weight: bold;
padding: 20px;
}
.logo {
text-align: left;
}
.footer {
float:right;
margin-right:10px;
}
</style>
</head>
<body>
<div class="container">
<div class="content">
<div class="title">{{ .Code }} {{ .Message }} </div>
</div>
</div>
</body>
</html>`))
)
Functions ¶
func Logger ¶
func Logger() logger.AbstractLogger
func RegisterOnInterrupt ¶
func RegisterOnInterrupt(handler func())
func RegisterViewEngine ¶
func RegisterViewEngine(engine render.AbstractRenderer)
Types ¶
type AbstractReadonlyConfiguration ¶
type AbstractReadonlyConfiguration interface {
GetServerName() string
GetCharset() string
GetAutoParseForm() bool
GetMaxMultipartMemory() int64
GetAutoParseControllerResult() bool
GetCookieTranscoder() cookie_transcoder.AbstractCookieTranscoder
}
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)
OPTIONS(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)
}
type Application ¶
type Application struct {
*Router
ReadonlyConfiguration AbstractReadonlyConfiguration
// contains filtered or unexported fields
}
func New ¶
func New() *Application
func (*Application) Run ¶
func (a *Application) Run(srv ServerHandler, opts ...Configurator)
func (*Application) ServeHTTP ¶
func (a *Application) ServeHTTP(res http.ResponseWriter, req *http.Request)
func (*Application) SetNotFound ¶
func (a *Application) SetNotFound(handler Handler)
func (*Application) SetRecoverHandler ¶
func (a *Application) SetRecoverHandler(handler Handler)
func (*Application) StartPProf ¶
func (a *Application) StartPProf()
type Configuration ¶
type Configuration struct {
CookieTranscoder cookie_transcoder.AbstractCookieTranscoder
// contains filtered or unexported fields
}
func (*Configuration) GetAutoParseControllerResult ¶
func (c *Configuration) GetAutoParseControllerResult() bool
func (*Configuration) GetAutoParseForm ¶
func (c *Configuration) GetAutoParseForm() bool
func (*Configuration) GetCharset ¶
func (c *Configuration) GetCharset() string
func (*Configuration) GetCookieTranscoder ¶
func (c *Configuration) GetCookieTranscoder() cookie_transcoder.AbstractCookieTranscoder
func (*Configuration) GetMaxMultipartMemory ¶
func (c *Configuration) GetMaxMultipartMemory() int64
func (*Configuration) GetServerName ¶
func (c *Configuration) GetServerName() string
type Configurator ¶
type Configurator func(o *Configuration)
func WithAutoParseControllerResult ¶
func WithAutoParseControllerResult(auto bool) Configurator
func WithAutoParseForm ¶
func WithAutoParseForm(autoParseForm bool) Configurator
func WithCharset ¶
func WithCharset(charset string) Configurator
func WithCookieTranscoder ¶
func WithCookieTranscoder(transcoder cookie_transcoder.AbstractCookieTranscoder) Configurator
func WithMaxMultipartMemory ¶
func WithMaxMultipartMemory(mem int64) Configurator
func WithServerName ¶
func WithServerName(srvName string) Configurator
func WithoutStartupLog ¶
func WithoutStartupLog(hide bool) Configurator
type Context ¶
type Context struct {
// Temporary recording error information
Msg string
// contains filtered or unexported fields
}
func (*Context) ExistsCookie ¶
func (*Context) GetFloat64 ¶
func (*Context) GetStrings ¶
func (*Context) Logger ¶
func (c *Context) Logger() logger.AbstractLogger
func (*Context) PostFloat64 ¶
func (*Context) RemoveCookie ¶
func (*Context) Session ¶
func (c *Context) Session() sessions.AbstractSession
func (*Context) WriteString ¶
func (*Context) Writer ¶
func (c *Context) Writer(writers ...http.ResponseWriter) http.ResponseWriter
type Controller ¶
type Controller struct {
// contains filtered or unexported fields
}
func (*Controller) Cookie ¶
func (c *Controller) Cookie() *sessions.Cookie
func (*Controller) Ctx ¶
func (c *Controller) Ctx() *Context
func (*Controller) Logger ¶
func (c *Controller) Logger() logger.AbstractLogger
func (*Controller) Param ¶
func (c *Controller) Param() params
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
Render() *Render
Logger() logger.AbstractLogger
Session() sessions.AbstractSession
Cookie() *sessions.Cookie
}
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)
OPTIONS(path string, handle string, mws ...Handler)
// contains filtered or unexported methods
}
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) Handle ¶
func (r *Router) Handle(c IController) *Router
func (*Router) StaticFile ¶
type ServerHandler ¶
type ServerHandler func(*Application) error
func Addr ¶
func Addr(addr string) ServerHandler
func Func ¶
func Func(f func() error) ServerHandler
func Server ¶
func Server(s *http.Server) ServerHandler
Source Files
¶
Click to show internal directories.
Click to hide internal directories.