xjhttp

package
v0.7.3 Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2021 License: MIT Imports: 17 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetAllFromBearerToken added in v0.3.0

func GetAllFromBearerToken(ctx *Context, AccessSecret string) (user, ext string, err error)

func GetAllFromToken added in v0.3.0

func GetAllFromToken(token, AccessSecret string) (user, ext string, err error)

func GetBearerToken added in v0.3.0

func GetBearerToken(ctx *Context) (string, error)

BearerToken格式为:bearer + token,取真正的token

func GetExtFromToken added in v0.3.0

func GetExtFromToken(token, AccessSecret string) (ext string, err error)

func GetUserFromBearerToken added in v0.3.0

func GetUserFromBearerToken(ctx *Context, AccessSecret string) (user string, err error)

func GetUserFromToken added in v0.3.0

func GetUserFromToken(token, AccessSecret string) (user string, err error)

Types

type AppConfig

type AppConfig struct {
	Profile       string                //dev,test,prod
	App           xjtypes.App           //服务的名称等
	Register      xjtypes.Register      //如果服务都注册到ETCD,这个可以不要
	Gateway       xjtypes.Gateway       //如果服务间的调用都通过rpc,这个可以不要
	Config        xjtypes.Config        //如果配置使用本地配置文件, 这个可以不要
	Etcd          xjtypes.Etcd          //http和rpc服务的注册管理
	Auth          xjtypes.Auth          //jwt验证的密钥和有效时间
	Datasource    xjtypes.Datasource    //数据源
	Redis         xjtypes.Redis         //缓存
	ElasticSearch xjtypes.ElasticSearch //es搜索
	Nsq           xjtypes.Nsq           //NSQ消息
}

type Context

type Context struct {
	Request  *http.Request
	Writer   http.ResponseWriter
	CacheMgr *xjcache.CacheMgr
	// contains filtered or unexported fields
}

func (*Context) Abort added in v0.3.2

func (c *Context) Abort()

func (*Context) Bind added in v0.3.0

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

func (*Context) BindQuery added in v0.4.0

func (c *Context) BindQuery(dst interface{})

func (*Context) Body

func (c *Context) Body() (string, error)

func (*Context) BodyGetInt added in v0.6.6

func (c *Context) BodyGetInt(key string) (int, error)

func (*Context) BodyGetInt64 added in v0.6.6

func (c *Context) BodyGetInt64(key string) (int64, error)

func (*Context) BodyGetStr added in v0.6.7

func (c *Context) BodyGetStr(key string) (string, error)

func (*Context) BodyGetUint added in v0.6.6

func (c *Context) BodyGetUint(key string) (uint, error)

func (*Context) BodyGetUint64 added in v0.6.6

func (c *Context) BodyGetUint64(key string) (uint64, error)

func (*Context) BodyJson

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

func (*Context) DefaultQuery added in v0.2.9

func (c *Context) DefaultQuery(key, def string) string

func (*Context) Error

func (c *Context) Error(code int, err error)

func (*Context) Fail

func (c *Context) Fail(code int, msg string)

func (*Context) Form

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

func (*Context) GetCache added in v0.3.0

func (c *Context) GetCache(AccessSecret string, Caches *xjcache.CacheMgr, key string) interface{}

func (*Context) GetCacheInt added in v0.3.0

func (c *Context) GetCacheInt(AccessSecret string, Caches *xjcache.CacheMgr, key string) int

func (*Context) GetCacheInt64 added in v0.3.0

func (c *Context) GetCacheInt64(AccessSecret string, Caches *xjcache.CacheMgr, key string) int64

func (*Context) GetCacheString added in v0.3.0

func (c *Context) GetCacheString(AccessSecret string, Caches *xjcache.CacheMgr, key string) string

func (*Context) GetHeader

func (c *Context) GetHeader(key string) string

func (*Context) GetString added in v0.3.0

func (c *Context) GetString(key string) string

func (*Context) JSON

func (c *Context) JSON(code int, obj interface{})

func (*Context) Make

func (c *Context) Make(code int, rcode int, data interface{}, msg string)

func (*Context) MultipartForm added in v0.3.6

func (c *Context) MultipartForm() (*multipart.Form, error)

func (*Context) Next added in v0.3.2

func (c *Context) Next()

func (*Context) Param added in v0.3.0

func (c *Context) Param(key string) string

func (*Context) ParamFloat64 added in v0.3.6

func (c *Context) ParamFloat64(key string) (float64, error)

func (*Context) ParamInt added in v0.3.6

func (c *Context) ParamInt(key string) (int, error)

func (*Context) ParamInt64 added in v0.3.6

func (c *Context) ParamInt64(key string) (int64, error)

func (*Context) PathParam

func (c *Context) PathParam(index int) string

func (*Context) PathParamInt

func (c *Context) PathParamInt(index int) (int, error)

func (*Context) PathParamInt64

func (c *Context) PathParamInt64(index int) (int64, error)

func (*Context) Query added in v0.2.9

func (c *Context) Query(key string) string

func (*Context) QueryAll

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

func (*Context) QueryInt

func (c *Context) QueryInt(key string) (int, error)

func (*Context) QueryInt64

func (c *Context) QueryInt64(key string) (int64, error)

func (*Context) QueryIntDefault

func (c *Context) QueryIntDefault(key string, def int) (int, error)

func (*Context) QueryMap

func (c *Context) QueryMap() (m map[string]interface{})

func (*Context) QueryStr

func (c *Context) QueryStr(key string) string

func (*Context) QueryStruct

func (c *Context) QueryStruct(dst interface{})

func (*Context) String

func (c *Context) String(code int, format string, values ...interface{})

func (*Context) Success

func (c *Context) Success(code int, data interface{})

func (*Context) TraceInfo added in v0.4.3

func (c *Context) TraceInfo(msg string)

type Engine

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

func Default

func Default() *Engine

func (*Engine) DELETE

func (engine *Engine) DELETE(pattern, power string, handler func(*Context))

func (*Engine) GET

func (engine *Engine) GET(pattern, power string, handler func(*Context))

func (*Engine) GetRoute added in v0.3.0

func (engine *Engine) GetRoute(mapRoute map[int]Route) Route

func (*Engine) Group added in v0.2.9

func (engine *Engine) Group(group string) *RouterGroup

func (*Engine) HEAD

func (engine *Engine) HEAD(pattern, power string, handler func(*Context))

func (*Engine) HandleFunc

func (engine *Engine) HandleFunc(method, pattern, power string, handler func(*Context))

func (*Engine) OPTIONS

func (engine *Engine) OPTIONS(pattern, power string, handler func(*Context))

func (*Engine) PATCH

func (engine *Engine) PATCH(pattern, power string, handler func(*Context))

func (*Engine) POST

func (engine *Engine) POST(pattern, power string, handler func(*Context))

func (*Engine) PUT

func (engine *Engine) PUT(pattern, power string, handler func(*Context))

func (*Engine) PathMatch

func (engine *Engine) PathMatch(path, pattern string) int

func (*Engine) Redirect added in v0.2.9

func (engine *Engine) Redirect(relativePath, root string)

func (*Engine) Run

func (engine *Engine) Run(address string) (err error)

func (*Engine) ServeHTTP

func (engine *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)

func (*Engine) Static added in v0.2.9

func (engine *Engine) Static(relativePath, root string)

func (*Engine) Use added in v0.3.2

func (engine *Engine) Use(handler func(*Context))

Use attaches a global middleware to the router.

type HandlerFunc added in v0.3.2

type HandlerFunc func(*Context)

type Route

type Route struct {
	Method   string
	Pattern  string
	Handlers []HandlerFunc
	Power    string
}

type RouterGroup added in v0.2.9

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

func (*RouterGroup) DELETE added in v0.2.9

func (group *RouterGroup) DELETE(pattern, power string, handler func(*Context))

func (*RouterGroup) GET added in v0.2.9

func (group *RouterGroup) GET(pattern, power string, handler func(*Context))

func (*RouterGroup) POST added in v0.7.3

func (group *RouterGroup) POST(pattern, power string, handler func(*Context))

func (*RouterGroup) PUT added in v0.7.3

func (group *RouterGroup) PUT(pattern, power string, handler func(*Context))

Jump to

Keyboard shortcuts

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