Documentation ¶
Index ¶
- func GetControllerName(c Controllerable) string
- type App
- type Context
- func (c *Context) Bind(obj interface{}) error
- func (c *Context) BindJSON(obj interface{}) error
- func (c *Context) BindWith(obj interface{}, b binding.Binder) error
- func (c *Context) ContentType() string
- func (c *Context) Deadline() (deadline time.Time, ok bool)
- func (c *Context) Done() <-chan struct{}
- func (c *Context) Err() error
- func (c *Context) File(file string)
- func (c *Context) FindControllerRoutePath(name string, handler string) string
- func (c *Context) Get(key string) (value interface{}, exists bool)
- func (c *Context) JSON(statusCode int, content interface{})
- func (c *Context) Redirect(code int, location string)
- func (c *Context) Render(statusCode int, r render.Renderable)
- func (c *Context) Rendered() bool
- func (c *Context) Set(key string, value interface{})
- func (c *Context) String(statusCode int, format string, contents ...interface{})
- func (c *Context) Value(key interface{}) interface{}
- type Controller
- type ControllerManage
- type ControllerOption
- type ControllerRouteOption
- type Controllerable
- type HandlerFunc
- type MiddlewareFunc
- type Params
- type ResponseWriter
- func (w *ResponseWriter) CloseNotify() <-chan bool
- func (w *ResponseWriter) Flush()
- func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (w *ResponseWriter) Write(content []byte) (n int, err error)
- func (w *ResponseWriter) WriteHeader(statusCode int)
- func (w *ResponseWriter) Written() bool
- type Router
- func (r *Router) AddRoute(path string, method string, handler HandlerFunc)
- func (r *Router) DELETE(path string, handler HandlerFunc)
- func (r *Router) GET(path string, handler HandlerFunc)
- func (r *Router) HEAD(path string, handler HandlerFunc)
- func (r *Router) MatchRoute(path string, method string) (handler HandlerFunc, params Params, redirect bool)
- func (router *Router) Mount(mountPath string, mountedRouter *Router)
- func (r *Router) OPTIONS(path string, handler HandlerFunc)
- func (r *Router) PATCH(path string, handler HandlerFunc)
- func (r *Router) POST(path string, handler HandlerFunc)
- func (r *Router) PUT(path string, handler HandlerFunc)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetControllerName ¶
func GetControllerName(c Controllerable) string
GetControllerName return controller name, generate by type name if not manually set
Types ¶
type App ¶
type App struct { *Router *ControllerManage // contains filtered or unexported fields }
func (*App) Use ¶
func (app *App) Use(middlewreFunc MiddlewareFunc)
type Context ¶
type Context struct { Request *http.Request http.ResponseWriter Params Params // contains filtered or unexported fields }
func NewContext ¶
func NewContext() *Context
func (*Context) ContentType ¶
func (*Context) FindControllerRoutePath ¶
FindControllerRoutePath Find controller action path, return first path if multi route registered, panic if not found
type Controller ¶
type Controller struct { Name string // contains filtered or unexported fields }
func (*Controller) AddRoutes ¶
func (c *Controller) AddRoutes(routeOptions ...ControllerRouteOption)
AddRoutes add customize route to controller
func (*Controller) ControllerName ¶
func (c *Controller) ControllerName() string
func (*Controller) GetRoutes ¶
func (c *Controller) GetRoutes() []ControllerRouteOption
func (*Controller) SetControllerName ¶
func (c *Controller) SetControllerName(name string)
type ControllerManage ¶
type ControllerManage struct {
// contains filtered or unexported fields
}
func (*ControllerManage) AddController ¶
func (m *ControllerManage) AddController(c Controllerable, controllerOption *ControllerOption)
AddController add newcontroller
func (*ControllerManage) FindControllerRoutePath ¶
func (m *ControllerManage) FindControllerRoutePath(name string, handler string, paramvalue ...string) string
FindControllerRoutePath Find controller action path, return first path if multi route registered, panic if not found paramvalue are pairs of param/value like "id", "2"
type ControllerOption ¶
type ControllerRouteOption ¶
type ControllerRouteOption struct { // handler method name Handler string // http method Method string // http methods Methods []string // route path Path string // route prefix Prefix string // override controller name Name string // route suffix Suffix string // as member route, like: "/users/1/xxx" Member bool // as collection route, like: "/users/xxx" Collection bool }
ControllerRouteOption options to customize controller route
type Controllerable ¶
type Controllerable interface { ControllerName() string SetControllerName(string) AddRoutes(...ControllerRouteOption) GetRoutes() []ControllerRouteOption }
type HandlerFunc ¶
type HandlerFunc func(c *Context)
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
type Params ¶
type Params httprouter.Params
type ResponseWriter ¶
type ResponseWriter struct { http.ResponseWriter // contains filtered or unexported fields }
func (*ResponseWriter) CloseNotify ¶
func (w *ResponseWriter) CloseNotify() <-chan bool
Implements the http.CloseNotify interface
func (*ResponseWriter) Hijack ¶
func (w *ResponseWriter) Hijack() (net.Conn, *bufio.ReadWriter, error)
Implements the http.Hijack interface
func (*ResponseWriter) WriteHeader ¶
func (w *ResponseWriter) WriteHeader(statusCode int)
func (*ResponseWriter) Written ¶
func (w *ResponseWriter) Written() bool
type Router ¶
type Router struct { httprouter.Router // contains filtered or unexported fields }
func (*Router) AddRoute ¶
func (r *Router) AddRoute(path string, method string, handler HandlerFunc)
func (*Router) DELETE ¶
func (r *Router) DELETE(path string, handler HandlerFunc)
func (*Router) GET ¶
func (r *Router) GET(path string, handler HandlerFunc)
func (*Router) HEAD ¶
func (r *Router) HEAD(path string, handler HandlerFunc)
func (*Router) MatchRoute ¶
func (*Router) OPTIONS ¶
func (r *Router) OPTIONS(path string, handler HandlerFunc)
func (*Router) PATCH ¶
func (r *Router) PATCH(path string, handler HandlerFunc)
func (*Router) POST ¶
func (r *Router) POST(path string, handler HandlerFunc)
func (*Router) PUT ¶
func (r *Router) PUT(path string, handler HandlerFunc)
Source Files ¶
Directories ¶
Path | Synopsis |
---|---|
Package binding idea & some code from gin binding https://github.com/gin-gonic/gin/tree/master/binding , thanks gin
|
Package binding idea & some code from gin binding https://github.com/gin-gonic/gin/tree/master/binding , thanks gin |
Click to show internal directories.
Click to hide internal directories.