app

package
v0.1.13 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 29, 2020 License: Apache-2.0 Imports: 32 Imported by: 2

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AppDefer

func AppDefer(deferFun ...func())

AppDefer 应用退出后置操作

func AppStart

func AppStart(appSrv AppSrv)

启动应用

func ExitWaitFunDo

func ExitWaitFunDo(doFun func())

ExitWaitFunDo 退出后等待处理完成

func ListenStop

func ListenStop(stopSig chan StopSignal)

ListenStop 订阅app退出信号

func ParseForm

func ParseForm(form url.Values, obj interface{}) error

ParseForm will parse form values to struct via tag.

func ParseJson

func ParseJson(jsonByte []byte, obj interface{}) error

Types

type AppSrv

type AppSrv interface {
	ServeMux()
	Register()
}

AppSrv 应用注册接口

type Context

type Context struct {
	CsrfToken   string
	OrangeInput *request.OrangeInput
	Args        []string
	// contains filtered or unexported fields
}

func NewCtx

func NewCtx(ctx context.Context, w http.ResponseWriter, r *http.Request, args ...string) *Context

func (*Context) AddIncludeTmpl added in v0.1.9

func (c *Context) AddIncludeTmpl(viewName string)

AddIncludeTmpl添加引入模版

func (*Context) AppUpload

func (c *Context) AppUpload(formName string) (savePath string, err error)

AppUpload 匹配配置文件中的大小限制和扩展名限制

func (*Context) AppUploadToData added in v0.1.12

func (c *Context) AppUploadToData(formName string) (*UploadFile, error)

AppUploadToData 将上传后的文件返回 []byte 数据

func (*Context) Context

func (c *Context) Context() context.Context

func (*Context) GetCtxParam

func (c *Context) GetCtxParam(key string) (val interface{})

func (*Context) Header

func (c *Context) Header() http.Header

func (*Context) HttpError added in v0.1.3

func (c *Context) HttpError(error string, code int)

func (*Context) Input

func (c *Context) Input() url.Values

Input returns the input data map from POST or PUT request body and query string.

func (*Context) ParseForm

func (c *Context) ParseForm(obj interface{}) error

ParseForm maps input data map to obj struct.

func (*Context) Redirect added in v0.1.9

func (c *Context) Redirect(tourl string)

func (*Context) Request

func (c *Context) Request() *http.Request

func (*Context) ResponseHeader

func (c *Context) ResponseHeader() http.Header

func (*Context) ResponseReset added in v0.1.4

func (c *Context) ResponseReset()

func (*Context) ResponseWrite

func (c *Context) ResponseWrite(b []byte) error

func (*Context) ResponseWriteHeader added in v0.1.3

func (c *Context) ResponseWriteHeader(code int)

func (*Context) Session

func (c *Context) Session() session.Store

func (*Context) SetCookie

func (c *Context) SetCookie(cookie *http.Cookie)

func (*Context) SetCtxParam

func (c *Context) SetCtxParam(key string, value interface{})

func (*Context) SetRW

func (c *Context) SetRW(w http.ResponseWriter, r *http.Request)

func (*Context) ShareAssign added in v0.1.9

func (c *Context) ShareAssign(key string, viewData interface{})

ShareAssign 全局通用模板变量

func (*Context) ToJson

func (c *Context) ToJson(data interface{}) error

func (*Context) ToString

func (c *Context) ToString(data string) error

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

func (*Context) ViewHtml added in v0.1.4

func (c *Context) ViewHtml(viewName string, viewDatas ...interface{}) error

ViewHtml 快速渲染html视图

func (*Context) ViewText added in v0.1.4

func (c *Context) ViewText(viewName string, viewDatas ...interface{}) error

ViewHtml 快速渲染text视图

type ErrNoFile

type ErrNoFile struct {
	// contains filtered or unexported fields
}

func (ErrNoFile) Error

func (e ErrNoFile) Error() string

type HandlerFunc

type HandlerFunc func(*Context) error

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 RouterServer

type RouterServer struct {
	// contains filtered or unexported fields
}

func NewRouter

func NewRouter(prefix string, middlewares ...MiddleWare) *RouterServer

func (*RouterServer) ALL

func (r *RouterServer) ALL(patten string, handler func(ctx *Context) error)

ALL 兼容所有请求

func (*RouterServer) DELETE

func (r *RouterServer) DELETE(patten string, handler func(ctx *Context) error)

DELETE 注册 delete 请求

func (*RouterServer) GET

func (r *RouterServer) GET(patten string, handler func(ctx *Context) error)

GET 注册 get 请求

func (*RouterServer) GroupRouter

func (r *RouterServer) GroupRouter(prefix string, middlewares ...MiddleWare) *RouterServer

GroupRouter 子群组路由

func (*RouterServer) POST

func (r *RouterServer) POST(patten string, handler func(ctx *Context) error)

POST 注册 post 请求

func (*RouterServer) PUT

func (r *RouterServer) PUT(patten string, handler func(ctx *Context) error)

PUT 注册 put 请求

type StopSignal

type StopSignal int32

type UploadFile

type UploadFile struct {
	FileName  string
	Extension string
	FileSize  int64
	FileByte  []byte
	SavePath  string
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL