xjhttp

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2024 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.7.4

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

func GetAllFromToken added in v0.7.4

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

func GetBearerToken added in v0.7.4

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

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

func GetExtFromToken added in v0.7.4

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

func GetUserFromBearerToken added in v0.7.4

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

func GetUserFromToken added in v0.7.4

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

Types

type AppConfig added in v0.0.8

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 added in v0.0.8

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

func (*Context) Abort added in v0.7.4

func (c *Context) Abort()

func (*Context) Bind added in v0.7.4

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

func (*Context) BindQuery added in v0.7.4

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

func (*Context) Body added in v0.1.4

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

func (*Context) BodyGetInt added in v0.7.4

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

func (*Context) BodyGetInt64 added in v0.7.4

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

func (*Context) BodyGetStr added in v0.7.4

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

func (*Context) BodyGetUint added in v0.7.4

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

func (*Context) BodyGetUint64 added in v0.7.4

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

func (*Context) BodyJson added in v0.1.4

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

func (*Context) DefaultQuery added in v0.7.4

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

func (*Context) Error added in v0.0.8

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

func (*Context) Fail added in v0.0.8

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

func (*Context) Form added in v0.1.4

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

func (*Context) GetCache added in v0.7.4

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

func (*Context) GetCacheInt added in v0.7.4

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

func (*Context) GetCacheInt64 added in v0.7.4

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

func (*Context) GetCacheString added in v0.7.4

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

func (*Context) GetHeader added in v0.1.6

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

func (*Context) GetString added in v0.7.4

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

func (*Context) JSON added in v0.0.8

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

func (*Context) Make added in v0.0.8

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

func (*Context) MultipartForm added in v0.7.4

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

func (*Context) Next added in v0.7.4

func (c *Context) Next()

func (*Context) Param added in v0.7.4

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

func (*Context) ParamFloat64 added in v0.7.4

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

func (*Context) ParamInt added in v0.7.4

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

func (*Context) ParamInt64 added in v0.7.4

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

func (*Context) ParamUint64 added in v0.8.0

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

func (*Context) PathParam added in v0.1.0

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

func (*Context) PathParamInt added in v0.1.7

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

func (*Context) PathParamInt64 added in v0.1.7

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

func (*Context) Query added in v0.7.4

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

func (*Context) QueryAll added in v0.0.8

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

func (*Context) QueryBool added in v0.8.5

func (c *Context) QueryBool(key string) bool

func (*Context) QueryInt added in v0.1.0

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

func (*Context) QueryInt64 added in v0.1.0

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

func (*Context) QueryIntDefault added in v0.1.5

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

func (*Context) QueryMap added in v0.1.3

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

func (*Context) QueryStr added in v0.0.8

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

func (*Context) QueryStruct added in v0.1.5

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

func (*Context) QueryUint32 added in v0.7.9

func (c *Context) QueryUint32(key string) (uint32, error)

func (*Context) QueryUint32Default added in v0.7.9

func (c *Context) QueryUint32Default(key string, def uint32) (uint32, error)

func (*Context) QueryUint64 added in v0.7.9

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

func (*Context) QueryUint64Default added in v0.7.9

func (c *Context) QueryUint64Default(key string, def uint64) (uint64, error)

func (*Context) R added in v0.8.4

func (c *Context) R(r xjtypes.R)

func (*Context) RCode added in v0.8.4

func (c *Context) RCode(code int, r xjtypes.R)

func (*Context) String added in v0.0.8

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

func (*Context) Success added in v0.0.8

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

func (*Context) TraceInfo added in v0.7.4

func (c *Context) TraceInfo(msg string)

type Engine

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

func Default

func Default() *Engine

func (*Engine) DELETE added in v0.0.8

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

func (*Engine) GET added in v0.0.8

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

func (*Engine) GetRoute added in v0.7.4

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

func (*Engine) Group added in v0.7.4

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

func (*Engine) HEAD added in v0.0.8

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 added in v0.0.8

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

func (*Engine) PATCH added in v0.0.8

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

func (*Engine) POST added in v0.0.8

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

func (*Engine) PUT added in v0.0.8

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.7.4

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.7.4

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

func (*Engine) Use added in v0.7.4

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

Use attaches a global middleware to the router.

type HandlerFunc added in v0.7.4

type HandlerFunc func(*Context)

type Route

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

type RouterGroup added in v0.7.4

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

func (*RouterGroup) DELETE added in v0.7.4

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

func (*RouterGroup) GET added in v0.7.4

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

func (*RouterGroup) OPTIONS added in v0.7.5

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

func (*RouterGroup) POST added in v0.7.4

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

func (*RouterGroup) PUT added in v0.7.4

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