Documentation ¶
Index ¶
- Constants
- Variables
- func AddMethods(method string)
- func Dir(root string, listDirectory bool) http.FileSystem
- type AllocateContextFunc
- type Context
- type EnginOption
- type Engine
- func (e *Engine) Delims(left, right string) *Engine
- func (e *Engine) LoadHTMLGlob(pattern string)
- func (e *Engine) NoMethod(handler HandlerFunc, middleware ...MiddlewareFunc) *Engine
- func (e *Engine) NoRoute(handler HandlerFunc, middleware ...MiddlewareFunc) *Engine
- func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (e *Engine) SetHTMLTemplate(templ *template.Template)
- func (e *Engine) Use(middleware ...MiddlewareFunc) IRoutes
- type HandlerFunc
- type IRoutes
- type LocalResponseWriter
- type Map
- type MiddlewareFunc
- type Param
- type Params
- type ResponseWriter
- type RouterGroup
- func (r *RouterGroup) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Delete(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Get(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Group(prefix string, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Handle(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Head(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Options(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Patch(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Post(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Put(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Static(path, root string, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) StaticFS(relativePath string, fs http.FileSystem, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) StaticFile(path, filepath string, middleware ...MiddlewareFunc) IRoutes
- func (r *RouterGroup) Use(middleware ...MiddlewareFunc) IRoutes
Constants ¶
Variables ¶
var ( ErrRedirect = errors.New("redirect") ErrIgnore = errors.New("ignore") )
Functions ¶
func Dir ¶
func Dir(root string, listDirectory bool) http.FileSystem
Dir returns a http.FileSystem that can be used by http.FileServer(). It is used internally in router.Static(). if listDirectory == true, then it works the same as http.Dir() otherwise it returns a filesystem that prevents http.FileServer() to list the directory files.
Types ¶
type AllocateContextFunc ¶
type AllocateContextFunc func() Context
type Context ¶
type Context interface { Reset(w http.ResponseWriter, r *http.Request, fullPath string, params *Params) Request() *http.Request SetRequest(*http.Request) Writer() ResponseWriter File(filePath string) Param(param string) string SetTenant(tenant models.Tenant) GetTenant() models.Tenant SetLoginUser(loginUser models.LoginUser) GetLoginUser() models.LoginUser IsSignedIn() bool SignedIn(isSigned bool) Logger() logger.Logger FullPath() string ClientIP() string Status(code int) HTML(code int, name string, obj interface{}) JSON(code int, obj interface{}) Redirect(code int, url string) BindJSON(obj interface{}) error BindQuery(obj interface{}) error BindParameter(obj interface{}) error MustBindWith(obj interface{}, b binding.Binding) error Query(key string) string GetHeader(key string) string }
type EnginOption ¶
type EnginOption interface {
// contains filtered or unexported methods
}
func WithAllocateContext ¶
func WithAllocateContext(fn AllocateContextFunc) EnginOption
type Engine ¶
type Engine struct { RouterGroup TmplFunMap template.FuncMap HTMLRender render.HTMLRender TrustedPlatform string AppEngine bool ForwardedByClientIP bool RemoteIPHeaders []string Logger logger.Logger // contains filtered or unexported fields }
func New ¶
func New(opts ...EnginOption) *Engine
func (*Engine) LoadHTMLGlob ¶
func (*Engine) NoMethod ¶
func (e *Engine) NoMethod(handler HandlerFunc, middleware ...MiddlewareFunc) *Engine
func (*Engine) NoRoute ¶
func (e *Engine) NoRoute(handler HandlerFunc, middleware ...MiddlewareFunc) *Engine
func (*Engine) SetHTMLTemplate ¶
func (*Engine) Use ¶
func (e *Engine) Use(middleware ...MiddlewareFunc) IRoutes
type HandlerFunc ¶
type IRoutes ¶
type IRoutes interface { Use(middleware ...MiddlewareFunc) IRoutes Handle(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes Get(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes Post(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes Put(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes Delete(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes Patch(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes Options(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes Head(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes StaticFile(path, filepath string, middleware ...MiddlewareFunc) IRoutes Static(path, root string, middleware ...MiddlewareFunc) IRoutes StaticFS(path string, fs http.FileSystem, middleware ...MiddlewareFunc) IRoutes Group(prefix string, middleware ...MiddlewareFunc) IRoutes }
type LocalResponseWriter ¶
type LocalResponseWriter struct {
// contains filtered or unexported fields
}
type MiddlewareFunc ¶
type MiddlewareFunc func(next HandlerFunc) HandlerFunc
type Params ¶
type Params []Param
Params is a Param-slice, as returned by the router. The slice is ordered, the first URL parameter is also the first slice value. It is therefore safe to read values by the index.
type ResponseWriter ¶
type ResponseWriter interface { http.ResponseWriter http.Hijacker http.Flusher // Returns the HTTP response status code of the current request. Status() int // Returns the number of bytes already written into the response http body. // See Written() Size() int // Writes the string into the response body. WriteString(string) (int, error) // Returns true if the response body was already written. Written() bool // Forces to write the http header (status code + headers). WriteHeaderNow() // get the http.Pusher for server push Pusher() http.Pusher // contains filtered or unexported methods }
type RouterGroup ¶
type RouterGroup struct {
// contains filtered or unexported fields
}
func (*RouterGroup) Any ¶
func (r *RouterGroup) Any(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
Any anyMethodsに登録されているメソッドを登録
func (*RouterGroup) Delete ¶
func (r *RouterGroup) Delete(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
Delete DELETE
func (*RouterGroup) Get ¶
func (r *RouterGroup) Get(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
Get GET
func (*RouterGroup) Group ¶
func (r *RouterGroup) Group(prefix string, middleware ...MiddlewareFunc) IRoutes
Group ルーターグループ
func (*RouterGroup) Handle ¶
func (r *RouterGroup) Handle(method, path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
Handle handlerの登録
func (*RouterGroup) Head ¶
func (r *RouterGroup) Head(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
Head HEAD
func (*RouterGroup) Options ¶
func (r *RouterGroup) Options(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
Options OPTIONS
func (*RouterGroup) Patch ¶
func (r *RouterGroup) Patch(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
Patch PATCH
func (*RouterGroup) Post ¶
func (r *RouterGroup) Post(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
Post POST
func (*RouterGroup) Put ¶
func (r *RouterGroup) Put(path string, handler HandlerFunc, middleware ...MiddlewareFunc) IRoutes
Put PUT
func (*RouterGroup) Static ¶
func (r *RouterGroup) Static(path, root string, middleware ...MiddlewareFunc) IRoutes
Static 静的ファイルがあるディレクトリをhandlerに登録
func (*RouterGroup) StaticFS ¶
func (r *RouterGroup) StaticFS(relativePath string, fs http.FileSystem, middleware ...MiddlewareFunc) IRoutes
StaticFS 静的ファイルを配信するhandlerを登録
func (*RouterGroup) StaticFile ¶
func (r *RouterGroup) StaticFile(path, filepath string, middleware ...MiddlewareFunc) IRoutes
StaticFile 単一ファイルを配信するhandlerを登録
func (*RouterGroup) Use ¶
func (r *RouterGroup) Use(middleware ...MiddlewareFunc) IRoutes
Use ルーターレベルでのミドルウェアの追加