Documentation
¶
Index ¶
- Constants
- type Action
- type Context
- type Group
- func (g *Group) AddMiddleware(f func(Context) error) Middleware
- func (g *Group) Get(path string) *Route
- func (g *Group) GetAction(f func(Context) error) *Route
- func (g *Group) GetSecureAction(f func(Context) error) *Route
- func (g *Group) HandleWebsocket(path string) *Websocket
- func (g *Group) Post(path string) *Route
- func (g *Group) PostAction(f func(Context) error) *Route
- func (g *Group) PostSecureAction(f func(Context) error) *Route
- func (g *Group) RemoveRoute(method, path string)
- func (g *Group) SetPrefixPath(path string)
- type Middleware
- type Proxy
- type Render
- type Request
- type RequestHeader
- type Response
- type ResponseHeader
- type Route
- type Server
- func (s *Server) AddMiddleware(f func(Context) error) Middleware
- func (s *Server) AddProxy(address string) *Proxy
- func (s *Server) Connect() error
- func (s *Server) Database() *dbm.Connection
- func (s *Server) FileRoute(path, dest, redirectTo string) error
- func (s *Server) FileRouteRemove(path string) error
- func (s *Server) Get(path string) *Route
- func (s *Server) GetAction(f func(Context) error) *Route
- func (s *Server) Group(name string) *Group
- func (s *Server) HandleWebsocket(path string) *Websocket
- func (s *Server) HasGroup(name string) bool
- func (s *Server) MaxRequestSize(size int)
- func (s *Server) NormalizeFunc(n bool)
- func (s *Server) OpenDatabase(driver, host string, port int, username, password, name string) error
- func (s *Server) Post(path string) *Route
- func (s *Server) PostAction(f func(Context) error) *Route
- func (s *Server) PostSecureAction(f func(Context) error) *Route
- func (s *Server) Serve(port int) error
- func (s *Server) ServeUnix(filename string) error
- func (s *Server) SetDatabase(cn *dbm.Connection)
- func (s *Server) SetLogger(debug func(...interface{}), info func(...interface{}), ...)
- func (s *Server) SetRender(r Render)
- func (s *Server) Shutdown() error
- type ServerOptions
- type Session
- type Websocket
- type Writer
Constants ¶
View Source
const ( //MethodGet GET MethodGet string = fasthttp.MethodGet //MethodPost POST MethodPost string = fasthttp.MethodPost //StatusBadRequest ... StatusBadRequest = fasthttp.StatusBadRequest StatusUnauthorized = fasthttp.StatusUnauthorized //StatusNotFound ... StatusForbidden = fasthttp.StatusForbidden //StatusNotFound ... StatusNotFound = fasthttp.StatusNotFound //StatusOK ... StatusOK = 200 //StatusInternalServerError ... StatusInternalServerError = fasthttp.StatusInternalServerError //StatusBadGateway ... StatusBadGateway = 502 )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Context ¶
type Context interface {
URL() *url.URL
Method() string
ContentType() string
RemoteIP() string
Write(value interface{}) error
//WriteBody write to body and ignoring the next action
WriteBody(contentType string, body []byte) error
//WriteStream
WriteStream(filename, contentType string, writeFunc func(Writer)) error
//Status stop execution and return status and message
Status(status int, msg string) error
//Error stop execution, rollback database transaction, and return status and message
Error(status int, msg string) error
//StatusBadRequest 400
StatusBadRequest(msg string) error
StatusUnauthorized(msg string) error
//StatusUnauthorized 403
StatusForbidden(msg string) error
//StatusNotFound 404
StatusNotFound(msg string) error
StatusInternalServerError(msg string) error
Redirect(url string) error
Request() Request
RequiredParams(names string) (json.Object, error)
Response() Response
Database() (*dbm.Connection, error)
Tx() (*dbm.Tx, error)
Session() Session
SetValue(name string, value interface{})
GetValue(name string) interface{}
}
Context ..
type Group ¶ added in v0.6.0
type Group struct {
// contains filtered or unexported fields
}
Group ..
func (*Group) AddMiddleware ¶ added in v0.6.0
func (g *Group) AddMiddleware(f func(Context) error) Middleware
func (*Group) GetSecureAction ¶ added in v0.7.0
func (*Group) HandleWebsocket ¶ added in v0.17.0
func (*Group) PostSecureAction ¶ added in v0.7.0
func (*Group) RemoveRoute ¶ added in v0.20.0
func (*Group) SetPrefixPath ¶ added in v0.16.1
type Middleware ¶
type Middleware interface {
//ForGroup set name for this middleware, this middleware only used by route that requiring the same name
ForGroup(string) Middleware
Secure() Middleware
}
Middleware ..
type Request ¶
type Request interface {
Header() *RequestHeader
Method() string
URL() *url.URL
JSON() json.Object
ValidJSON(names ...string) (json.Object, error)
Body() []byte
File(name string) (*multipart.FileHeader, error)
QueryParam(name string) string
}
Request ..
type RequestHeader ¶ added in v0.5.0
type RequestHeader struct {
// contains filtered or unexported fields
}
RequestHeader ...
func (*RequestHeader) Bytes ¶ added in v0.6.0
func (r *RequestHeader) Bytes() []byte
func (*RequestHeader) Cookie ¶ added in v0.15.0
func (r *RequestHeader) Cookie(key string) string
type ResponseHeader ¶ added in v0.5.1
type ResponseHeader struct {
// contains filtered or unexported fields
}
ResponseHeader ...
type Route ¶
type Route struct {
// contains filtered or unexported fields
}
Route ...
func (*Route) AddQueryAction ¶
AddQueryAction ...
func (*Route) ResetActions ¶ added in v0.17.4
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server ...
func (*Server) AddMiddleware ¶
func (s *Server) AddMiddleware(f func(Context) error) Middleware
AddMiddleware ..
func (*Server) FileRoute ¶ added in v0.4.0
FileRoute serve static file. Path parameter to determine url to be processed. Dest parameter will find directory of the file reside. RedirectTo parameter to redirect non existing file, this param can be used for SPA (ex. index.html).
func (*Server) FileRouteRemove ¶ added in v0.4.1
FileRouteRemove ...
func (*Server) HandleWebsocket ¶ added in v0.17.1
func (*Server) MaxRequestSize ¶ added in v0.11.1
func (*Server) NormalizeFunc ¶ added in v0.3.2
NormalizeFunc this func need to called before adding any routes. parameter n=true for renaming all route paths to lowercase, separated with underscore. Ex: /HelloWorld registered as /hello_world
func (*Server) OpenDatabase ¶
OpenDatabase ..
func (*Server) PostAction ¶ added in v0.7.0
func (*Server) PostSecureAction ¶ added in v0.7.0
func (*Server) SetDatabase ¶
func (s *Server) SetDatabase(cn *dbm.Connection)
type ServerOptions ¶ added in v0.21.0
type ServerOptions func(*Server)
func OptionTimeout ¶ added in v0.21.0
func OptionTimeout(timeout time.Duration) ServerOptions
type Session ¶
type Session interface {
Put(key string, value interface{})
Get(key string) interface{}
Remove(key string)
GetInt(key string) int
GetString(key string) string
}
Session ...
Source Files
¶
Click to show internal directories.
Click to hide internal directories.