Documentation ¶
Index ¶
- Constants
- Variables
- func AppDefer(deferFun ...func())
- func AppStart(appSrv AppSrv)
- func ExitWaitFunDo(doFun func())
- func HttpForbidden(w http.ResponseWriter, r *http.Request)
- func HttpNotFound(w http.ResponseWriter, r *http.Request)
- func ListenStop(stopSig chan StopSignal)
- func NewAssetsHandler(patten string, filePath string, autoindex FileServerType)
- func NewHttpHandler(patten string, handler http.Handler)
- func ParseForm(form url.Values, obj interface{}) error
- func ParseJson(jsonByte []byte, obj interface{}) error
- type AppSrv
- type Context
- func (c *Context) AddDelayAfterDo(handlerFunc func(ctx *Context), delay time.Duration)
- func (c *Context) AddIncludeTmpl(viewName string)
- func (c *Context) AppUpload(formName string) (savePath string, err error)
- func (c *Context) AppUploadToData(formName string) (*UploadFile, error)
- func (c *Context) Context() context.Context
- func (c *Context) GetCtxParam(key string) (val interface{})
- func (c *Context) GetMs() time.Duration
- func (c *Context) GetPathParam(name string) (val string)
- func (c *Context) GetPathParamToInt(name string) (val int)
- func (c *Context) Header() http.Header
- func (c *Context) HttpError(error string, code int)
- func (c *Context) Input() url.Values
- func (c *Context) ParseForm(obj interface{}) error
- func (c *Context) Redirect(tourl string)
- func (c *Context) Request() *http.Request
- func (c *Context) ResponseBody() []byte
- func (c *Context) ResponseHeader() http.Header
- func (c *Context) ResponseReset()
- func (c *Context) ResponseStatus() int
- func (c *Context) ResponseWrite(b []byte) error
- func (c *Context) ResponseWriteHeader(code int)
- func (c *Context) RoutePath() string
- func (c *Context) Session() session.Store
- func (c *Context) SetContext(ctx context.Context) context.Context
- func (c *Context) SetCookie(cookie *http.Cookie)
- func (c *Context) SetCtxParam(key string, value interface{})
- func (c *Context) SetPanic(panicMsg interface{})
- func (c *Context) SetRW(w http.ResponseWriter, r *http.Request)
- func (c *Context) SetResponseStatus(status int)
- func (c *Context) ShareAssign(key string, viewData interface{})
- func (c *Context) ToFile(filePath string, fileName string) error
- func (c *Context) ToImage(filePath string) error
- func (c *Context) ToJson(data interface{}) error
- func (c *Context) ToString(data string) error
- func (c *Context) UploadFromFile(formName string, saveDir string, verifyFunc func(file *UploadFile) error) (fileName string, err error)
- func (c *Context) UploadFromFileToData(formName string, saveDir string, verifyFunc func(file *UploadFile) error) (fileInfo *UploadFile, err error)
- func (c *Context) ViewHtml(viewName string, viewDatas ...interface{}) error
- func (c *Context) ViewText(viewName string, viewDatas ...interface{}) error
- type ErrNoFile
- type FileServerType
- type HandlerFunc
- type MiddleWare
- type MiddlewareFunc
- type OrangeServer
- type Router
- type RouterGroup
- func (r *RouterGroup) ALL(patten string, handler func(ctx *Context) error)
- func (r *RouterGroup) ASSETS(patten string, fielPath string, autoindex FileServerType)
- func (r *RouterGroup) DELETE(patten string, handler func(ctx *Context) error)
- func (r *RouterGroup) GET(patten string, handler func(ctx *Context) error)
- func (r *RouterGroup) GroupRouter(prefix string, middlewares ...MiddleWare) *RouterGroup
- func (r *RouterGroup) POST(patten string, handler func(ctx *Context) error)
- func (r *RouterGroup) PUT(patten string, handler func(ctx *Context) error)
- type StopSignal
- type UploadFile
Constants ¶
View Source
const ( AutoIndex = FileServerType(iota) DirDeny )
FileServer Params
Variables ¶
View Source
var ( NotFoundHandler = func(c *Context) error { c.responseStatus = http.StatusNotFound c.responseBody.Write([]byte("Not Found")) c.response.Header().Set("Content-Type", "text/plain; charset=utf-8") c.response.Header().Set("X-Content-Type-Options", "nosniff") return nil } MethodNotAllowedHandler = func(c *Context) error { c.responseStatus = http.StatusMethodNotAllowed c.responseBody.Write([]byte("Method Not Allowed")) c.response.Header().Set("Content-Type", "text/plain; charset=utf-8") c.response.Header().Set("X-Content-Type-Options", "nosniff") return nil } )
Error handlers
Functions ¶
func HttpForbidden ¶ added in v0.2.15
func HttpForbidden(w http.ResponseWriter, r *http.Request)
HttpForbidden replies to the request with an HTTP 403 Forbidden error.
func HttpNotFound ¶ added in v0.2.15
func HttpNotFound(w http.ResponseWriter, r *http.Request)
HttpNotFound replies to the request with an HTTP 404 not found error.
func NewAssetsHandler ¶ added in v0.2.15
func NewAssetsHandler(patten string, filePath string, autoindex FileServerType)
func NewHttpHandler ¶ added in v0.2.11
Types ¶
type Context ¶
type Context struct { CsrfToken string OrangeInput *request.OrangeInput // contains filtered or unexported fields }
func (*Context) AddDelayAfterDo ¶ added in v0.2.3
func (*Context) AddIncludeTmpl ¶ added in v0.1.9
AddIncludeTmpl添加引入模版
func (*Context) AppUploadToData ¶ added in v0.1.12
func (c *Context) AppUploadToData(formName string) (*UploadFile, error)
AppUploadToData 将上传后的文件返回 []byte 数据
func (*Context) GetCtxParam ¶
func (*Context) GetPathParam ¶ added in v0.2.3
func (*Context) GetPathParamToInt ¶ added in v0.2.3
func (*Context) Input ¶
Input returns the input data map from POST or PUT request body and query string.
func (*Context) ResponseBody ¶ added in v0.2.3
func (*Context) ResponseHeader ¶
func (*Context) ResponseReset ¶ added in v0.1.4
func (c *Context) ResponseReset()
func (*Context) ResponseStatus ¶ added in v0.2.12
func (*Context) ResponseWrite ¶
func (*Context) ResponseWriteHeader ¶ added in v0.1.3
func (*Context) SetContext ¶ added in v0.2.9
func (*Context) SetCtxParam ¶
func (*Context) SetResponseStatus ¶ added in v0.2.13
func (*Context) ShareAssign ¶ added in v0.1.9
ShareAssign 全局通用模板变量
func (*Context) UploadFromFile ¶
func (c *Context) UploadFromFile(formName string, saveDir string, verifyFunc func(file *UploadFile) error) (fileName string, err error)
UploadFromFile
func (*Context) UploadFromFileToData ¶ added in v0.1.12
func (c *Context) UploadFromFileToData(formName string, saveDir string, verifyFunc func(file *UploadFile) error) (fileInfo *UploadFile, err error)
UploadFromFileToData
type FileServerType ¶ added in v0.2.15
type FileServerType int
type HandlerFunc ¶
type MiddleWare ¶
type MiddleWare interface {
Func() MiddlewareFunc
}
type MiddlewareFunc ¶
type MiddlewareFunc func(HandlerFunc) HandlerFunc
MiddlewareFunc defines a function to process middleware.
type OrangeServer ¶ added in v0.1.6
type OrangeServer struct {
// contains filtered or unexported fields
}
func NewSrv ¶ added in v0.1.6
func NewSrv(httpSrv *http.Server) *OrangeServer
func (*OrangeServer) AppListenAndServe ¶ added in v0.1.6
func (app *OrangeServer) AppListenAndServe() error
func (*OrangeServer) GetListener ¶ added in v0.1.6
func (app *OrangeServer) GetListener() *net.TCPListener
func (*OrangeServer) ShutdownDo ¶ added in v0.1.6
func (app *OrangeServer) ShutdownDo(ctx context.Context) error
type Router ¶ added in v0.2.3
type Router struct {
// contains filtered or unexported fields
}
func (*Router) Find ¶ added in v0.2.3
func (r *Router) Find(method, path string, ctx *Context) (httpHandler HandlerFunc, httpMiddleware []MiddleWare)
Find 路由查找匹配到符合条件的url
type RouterGroup ¶ added in v0.2.3
type RouterGroup struct {
// contains filtered or unexported fields
}
func NewRouter ¶
func NewRouter(prefix string, middlewares ...MiddleWare) *RouterGroup
func (*RouterGroup) ALL ¶ added in v0.2.3
func (r *RouterGroup) ALL(patten string, handler func(ctx *Context) error)
ALL 兼容所有请求
func (*RouterGroup) ASSETS ¶ added in v0.2.15
func (r *RouterGroup) ASSETS(patten string, fielPath string, autoindex FileServerType)
Assets 注册静态资源目录
func (*RouterGroup) DELETE ¶ added in v0.2.3
func (r *RouterGroup) DELETE(patten string, handler func(ctx *Context) error)
DELETE 注册 delete 请求
func (*RouterGroup) GET ¶ added in v0.2.3
func (r *RouterGroup) GET(patten string, handler func(ctx *Context) error)
GET 注册 get 请求
func (*RouterGroup) GroupRouter ¶ added in v0.2.3
func (r *RouterGroup) GroupRouter(prefix string, middlewares ...MiddleWare) *RouterGroup
GroupRouter 子群组路由
type StopSignal ¶
type StopSignal int32
Click to show internal directories.
Click to hide internal directories.