wkhttp

package
v1.0.5 Latest Latest
Warning

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

Go to latest
Published: Nov 1, 2023 License: Apache-2.0 Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetLoginUID

func GetLoginUID(token string, tokenPrefix string, cache cache.Cache) string

GetLoginUID GetLoginUID

Types

type Context

type Context struct {
	*gin.Context
	// contains filtered or unexported fields
}

Context Context

func (*Context) CheckLoginRole

func (c *Context) CheckLoginRole() error

CheckLoginRole 检查登录角色权限

func (*Context) GetAppID

func (c *Context) GetAppID() string

GetAppID appID

func (*Context) GetLoginName

func (c *Context) GetLoginName() string

GetLoginName 获取当前登录的用户名字

func (*Context) GetLoginRole

func (c *Context) GetLoginRole() string

GetLoginRole 获取当前登录用户的角色

func (*Context) GetLoginUID

func (c *Context) GetLoginUID() string

GetLoginUID 获取当前登录的用户uid

func (*Context) GetPage

func (c *Context) GetPage() (pageIndex int64, pageSize int64)

GetPage 获取页参数

func (*Context) GetSpanContext

func (c *Context) GetSpanContext() opentracing.SpanContext

GetSpanContext 获取当前请求的span context

func (*Context) Response

func (c *Context) Response(data interface{})

Response Response

func (*Context) ResponseError

func (c *Context) ResponseError(err error)

ResponseError ResponseError

func (*Context) ResponseErrorWithStatus

func (c *Context) ResponseErrorWithStatus(err error, status int)

ResponseErrorWithStatus ResponseErrorWithStatus

func (*Context) ResponseErrorf

func (c *Context) ResponseErrorf(msg string, err error)

ResponseErrorf ResponseErrorf

func (*Context) ResponseOK

func (c *Context) ResponseOK()

ResponseOK 返回成功

func (*Context) ResponseWithStatus

func (c *Context) ResponseWithStatus(status int, data interface{})

ResponseWithStatus ResponseWithStatus

type HandlerFunc

type HandlerFunc func(c *Context)

HandlerFunc HandlerFunc

func CORSMiddleware

func CORSMiddleware() HandlerFunc

CORSMiddleware 跨域

type RouterGroup

type RouterGroup struct {
	*gin.RouterGroup
	L *WKHttp
}

RouterGroup RouterGroup

func (*RouterGroup) DELETE

func (r *RouterGroup) DELETE(relativePath string, handlers ...HandlerFunc)

DELETE DELETE

func (*RouterGroup) GET

func (r *RouterGroup) GET(relativePath string, handlers ...HandlerFunc)

GET GET

func (*RouterGroup) POST

func (r *RouterGroup) POST(relativePath string, handlers ...HandlerFunc)

POST POST

func (*RouterGroup) PUT

func (r *RouterGroup) PUT(relativePath string, handlers ...HandlerFunc)

PUT PUT

type UserRole

type UserRole string

UserRole 用户角色

const (
	// Admin 管理员
	Admin UserRole = "admin"
	// SuperAdmin 超级管理员
	SuperAdmin UserRole = "superAdmin"
)

type WKHttp

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

WKHttp WKHttp

func New

func New() *WKHttp

New New

func (*WKHttp) Any

func (l *WKHttp) Any(relativePath string, handlers ...HandlerFunc)

Any Any

func (*WKHttp) AuthMiddleware

func (l *WKHttp) AuthMiddleware(cache cache.Cache, tokenPrefix string) HandlerFunc

AuthMiddleware 认证中间件

func (*WKHttp) GET

func (l *WKHttp) GET(relativePath string, handlers ...HandlerFunc)

GET GET

func (*WKHttp) Group

func (l *WKHttp) Group(relativePath string, handlers ...HandlerFunc) *RouterGroup

Group Group

func (*WKHttp) HandleContext

func (l *WKHttp) HandleContext(c *Context)

HandleContext HandleContext

func (*WKHttp) LoadHTMLGlob

func (l *WKHttp) LoadHTMLGlob(pattern string)

LoadHTMLGlob LoadHTMLGlob

func (*WKHttp) POST

func (l *WKHttp) POST(relativePath string, handlers ...HandlerFunc)

POST POST

func (*WKHttp) Run

func (l *WKHttp) Run(addr ...string) error

Run Run

func (*WKHttp) RunTLS

func (l *WKHttp) RunTLS(addr, certFile, keyFile string) error

func (*WKHttp) ServeHTTP

func (l *WKHttp) ServeHTTP(w http.ResponseWriter, req *http.Request)

ServeHTTP ServeHTTP

func (*WKHttp) Static

func (l *WKHttp) Static(relativePath string, root string)

Static Static

func (*WKHttp) Use

func (l *WKHttp) Use(handlers ...HandlerFunc)

Use Use

func (*WKHttp) UseGin

func (l *WKHttp) UseGin(handlers ...gin.HandlerFunc)

UseGin UseGin

func (*WKHttp) WKHttpHandler

func (l *WKHttp) WKHttpHandler(handlerFunc HandlerFunc) gin.HandlerFunc

WKHttpHandler WKHttpHandler

Jump to

Keyboard shortcuts

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