Documentation
¶
Overview ¶
Package wits 路由路径参数
Index ¶
- Constants
- Variables
- func BasicAuth(username, password string) string
- func CreateTestContext(w http.ResponseWriter) (c *Context, r *Engine)
- func Debug(msg any, a ...any)
- func EnableGlobalTimeout()
- func EnableSession()
- func Error(msg any, a ...any)
- func Fatal(msg any, a ...any)
- func Get(pattern string) (value any, err error)
- func GetAddress() string
- func GetAll() (data map[string]any, err error)
- func GetAppName() string
- func GetArray(pattern string) (value []any)
- func GetBool(pattern string, def ...bool) (value bool)
- func GetInt(pattern string, def ...int) (value int)
- func GetInt64(pattern string, def ...int64) (value int64)
- func GetLogPrefix() string
- func GetPort() string
- func GetString(pattern string, def ...string) (value string)
- func GetStringMap(pattern string) (value map[string]any)
- func GetTime(pattern string, def ...time.Duration) (value time.Duration)
- func Info(msg any, a ...any)
- func IsOpenCors() bool
- func NewSessionManager(ttl int, store string)
- func RefreshToken(token string, date time.Duration, key []byte) (string, error)
- func RestResultEnable() bool
- func SetBanner(b string)
- func SetCookie(name, value string, ctx *Context, options ...*CookieOptions)
- func SetCtx(ctx context.Context)
- func SetGlobalTimeout(timeout time.Duration)
- func SetLog(l *logger.Logger)
- func Text(msg any, a ...any)
- func Warn(msg any, a ...any)
- type Accounts
- type AuthCheckHandler
- type CommonHandler
- type Context
- func (c *Context) Back(httpStatus int, code int, msg string, data any) error
- func (c *Context) BindJSON(obj any) error
- func (c *Context) BindXml(obj any) error
- func (c *Context) Body(key string) (v any)
- func (c *Context) BodyMap() map[string]any
- func (c *Context) ByteToString(status int, data []byte) error
- func (c *Context) ClientIP() string
- func (c *Context) ContentType() string
- func (c *Context) Cookie(name string) (string, error)
- func (c *Context) Copy() *Context
- func (c *Context) Ctx() context.Context
- func (c *Context) DEBUG(msg any, data ...any)
- func (c *Context) DisableDecoderUseNumber(fun func())
- func (c *Context) DisableStrictMatching(fun func())
- func (c *Context) ERROR(msg any, data ...any)
- func (c *Context) EnableDecoderUseNumber(fun func())
- func (c *Context) EnableStrictMatching(fun func())
- func (c *Context) ExpandAndPureJSON(status int, data any) error
- func (c *Context) ExpandJSON(status int, data any) error
- func (c *Context) ExpandXML(status int, data any) error
- func (c *Context) Fail(msg string, data any)
- func (c *Context) File(filepath string)
- func (c *Context) FileAttachment(filepath, filename string)
- func (c *Context) FileFromFS(filepath string, fs http.FileSystem)
- func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
- func (c *Context) Get(key string) (value any, exists bool)
- func (c *Context) GetBody(key string) (v any, ok bool)
- func (c *Context) GetBodyBool(key string) (v bool)
- func (c *Context) GetBodyFloat(key string) (v float64)
- func (c *Context) GetBodyInt(key string) (v int)
- func (c *Context) GetBodyInt64(key string) (v int64)
- func (c *Context) GetBodyLong(key string) (v int64)
- func (c *Context) GetBodyString(key string) (v string)
- func (c *Context) GetBool(key string) (b bool)
- func (c *Context) GetDuration(key string) (d time.Duration)
- func (c *Context) GetFloat64(key string) (f64 float64)
- func (c *Context) GetHandlerBizError() HandlerBizError
- func (c *Context) GetInt(key string) (i int)
- func (c *Context) GetInt64(key string) (i64 int64)
- func (c *Context) GetMethod() string
- func (c *Context) GetPath() string
- func (c *Context) GetPostForm(key string) (string, bool)
- func (c *Context) GetPostFormArray(key string) (values []string, ok bool)
- func (c *Context) GetPostFormMap(key string) (map[string]string, bool)
- func (c *Context) GetQuery(key string) (string, bool)
- func (c *Context) GetQueryArray(key string) (values []string, ok bool)
- func (c *Context) GetQueryBool(key string) (value bool)
- func (c *Context) GetQueryFloat64(key string) (value float64)
- func (c *Context) GetQueryInt(key string) (value int)
- func (c *Context) GetQueryInt64(key string) (value int64)
- func (c *Context) GetQueryMap(key string) (map[string]string, bool)
- func (c *Context) GetSessionId() string
- func (c *Context) GetString(key string) (s string)
- func (c *Context) GetStringMap(key string) (sm map[string]any)
- func (c *Context) GetStringMapString(key string) (sms map[string]string)
- func (c *Context) GetStringMapStringSlice(key string) (smss map[string][]string)
- func (c *Context) GetStringSlice(key string) (ss []string)
- func (c *Context) GetTime(key string) (t time.Time)
- func (c *Context) GetUint(key string) (ui uint)
- func (c *Context) GetUint64(key string) (ui64 uint64)
- func (c *Context) GetUser() string
- func (c *Context) HTMLTemplate(code int, name string, obj any) error
- func (c *Context) HandlerError(err *goerr.BizError)
- func (c *Context) Header(key, value string)
- func (c *Context) INFO(msg any, data ...any)
- func (c *Context) JSON(status int, data any) error
- func (c *Context) JSONP(code int, obj any)
- func (c *Context) MultipartForm() (*multipart.Form, error)
- func (c *Context) MustBindWith(obj any, b bind.Bind) error
- func (c *Context) MustGet(key string) any
- func (c *Context) NewSession() *session.Session
- func (c *Context) Panic(msg string)
- func (c *Context) PostForm(key string) (value string)
- func (c *Context) PostFormArray(key string) (values []string)
- func (c *Context) PostFormBool(key string) bool
- func (c *Context) PostFormFloat64(key string) float64
- func (c *Context) PostFormInt(key string) int
- func (c *Context) PostFormInt64(key string) int64
- func (c *Context) PostFormMap(key string) (dicts map[string]string)
- func (c *Context) PureJSON(status int, data any) error
- func (c *Context) Query(key string) (value string)
- func (c *Context) QueryArray(key string) (values []string)
- func (c *Context) QueryMap(key string) (dict map[string]string)
- func (c *Context) QueryOrDefault(key, defaultValue string) (value string)
- func (c *Context) Redirect(status int, url string) error
- func (c *Context) Referer() string
- func (c *Context) RemoteIP() string
- func (c *Context) Render(status int, r render.Render) error
- func (c *Context) RequestHeader(key string) string
- func (c *Context) Reset(w http.ResponseWriter, r *http.Request)
- func (c *Context) ReturnNow(status int)
- func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
- func (c *Context) Session() *session.Session
- func (c *Context) Set(key string, value any)
- func (c *Context) SetCookie(name, value string, options ...*CookieOptions)
- func (c *Context) SetHandlerBizError(handler HandlerBizError)
- func (c *Context) SetSameSite(samesite http.SameSite)
- func (c *Context) ShouldBindWith(obj any, b bind.Bind) error
- func (c *Context) Shutdown()
- func (c *Context) String(status int, format string, values ...any) error
- func (c *Context) Success(msg string, data any)
- func (c *Context) UserAgent() string
- func (c *Context) WARN(msg any, data ...any)
- func (c *Context) XML(status int, data any) error
- type CookieOptions
- type Engine
- func (e *Engine) AddFilter(check *Filter)
- func (e *Engine) AppName() string
- func (e *Engine) Delims(left, right string) *Engine
- func (e *Engine) GetAcl() acl.Acl
- func (r Engine) Group(name string) *routerGroup
- func (e *Engine) InitAclNodeList(fileName string)
- func (e *Engine) LoadHTMLFiles(files ...string)
- func (e *Engine) LoadHTMLGlob(pattern string)
- func (e *Engine) Logger() *logger.Logger
- func (e *Engine) RegisterOnShutdown(hook func())
- func (e *Engine) RegisterPostNewFunc(postNew func())
- func (e *Engine) RegisterPreRunFunc(preRun func())
- func (e *Engine) RegisterWarmupFunc(warmup func())
- func (e *Engine) RegistryServerPostProcessor(processor ServerPostProcessor)
- func (e *Engine) Run(address ...string)
- func (e *Engine) RunServer(address ...string)
- func (e *Engine) RunTLS(certFile, keyFile string, address ...string) (err error)
- func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
- func (e *Engine) SetAcl(acl acl.Acl)
- func (e *Engine) SetFuncMap(funcMap template.FuncMap)
- func (e *Engine) SetHTMLTemplate(template *template.Template)
- func (e *Engine) SetHandlerBizError(handler HandlerBizError)
- func (e *Engine) SetLogger(logger *logger.Logger)
- func (e *Engine) SetRouterHandler(handler RouterHandler)
- func (e *Engine) Shutdown()
- func (e *Engine) Use(middlewares ...MiddlewareFunc)
- func (r Engine) UseFront(middlewares ...MiddlewareFunc)
- func (e *Engine) Warmup()
- type Filter
- type FilterChain
- type HandlerBizError
- type HandlerFunc
- type JwtAuth
- type JwtToken
- type Map
- type MiddlewareFunc
- type NothingHandler
- type Response
- func (r *Response) Buffer() []byte
- func (r *Response) BufferString() string
- func (r *Response) ClearBuffer()
- func (r *Response) ContentType() string
- func (r *Response) Flush()
- func (r *Response) Header() http.Header
- func (r *Response) Hijack() (net.Conn, *bufio.ReadWriter, error)
- func (r *Response) Reset(w http.ResponseWriter)
- func (r *Response) SetHeader(name, value string)
- func (r *Response) Size() int64
- func (r *Response) Status() int
- func (r *Response) Unwrap() http.ResponseWriter
- func (r *Response) Write(b []byte) (n int, err error)
- func (r *Response) WriteHeader(status int)
- func (r *Response) WriteStatus(status int)
- func (r *Response) WriteStatusNow()
- func (r *Response) WriteString(s string) (n int, err error)
- type RestResult
- type RouterHandler
- type ServerPostProcessor
Constants ¶
const ( AuthKey = "Authorization" DefaultRealm = "Require" BasicPrefix = "Basic " UserKey = "UserKey" AuthErrorMsg = "AuthErrorMsg" JWTToken = "JWTToken" Bearer = "Bearer " RS256 = "RS256" RS512 = "RS512" RS384 = "RS384" HS256 = "HS256" HS384 = "HS384" HS512 = "HS512" WWWAuthenticate = "WWW-Authenticate" XRealIP = "X-Real-Ip" XForwardedFor = "X-Forwarded-For" XRequestID = "X-Request-Id" HeaderReferer = "Referer" HeaderUserAgent = "User-Agent" HeaderContentType = "Content-Type" HeaderContentDisposition = "Content-Disposition" DefaultLogPrefix = "WITS" AppLogPrefix = "app.log.prefix" AppServerCorsEnable = "app.server.cors.enable" AppName = "app.name" AppPort = "app.server.port" AppAddress = "app.server.address" AppSessionIdName = "app.session.id" AppSessionEnable = "app.session.enable" AppSessionTimeout = "app.session.timeout" AppSessionStore = "app.session.store" AppSessionFilterInclude = "app.session.filter.Include" AppSessionFilterExclude = "app.session.filter.Exclude" AppSessionCookiePath = "app.session.cookie.path" AppSessionCookieMaxAge = "app.session.cookie.maxAge" AppSessionCookieDomain = "app.session.cookie.domain" AppSessionCookieSecure = "app.session.cookie.secure" AppSessionCookieHttpOnly = "app.session.cookie.httponly" AppRestResultEnable = "app.rest.result.enable" AppRecordCostEnable = "app.server.cost.enable" AppGlobalTimeoutEnable = "app.server.global.timeout.enable" AppGlobalTimeout = "app.server.global.timeout" AppBannerEnable = "app.banner.enable" )
const ( DebugLevel = logger.DebugLevel InfoLevel = logger.InfoLevel WarnLevel = logger.WarnLevel ErrorLevel = logger.ErrorLevel TEXT = logger.TEXT )
const ANY = "ANY"
Variables ¶
var DefaultAuthCheckHandler = func(ctx *Context) { msg := ctx.GetString(AuthErrorMsg) if msg == "" { msg = "Authorization failure" } _ = ctx.String(http.StatusUnauthorized, msg) }
var GlobalTimeout time.Duration
var (
IdName string
)
Functions ¶
func CreateTestContext ¶
func CreateTestContext(w http.ResponseWriter) (c *Context, r *Engine)
func GetAddress ¶
func GetAddress() string
func GetAppName ¶
func GetAppName() string
func GetLogPrefix ¶
func GetLogPrefix() string
func GetStringMap ¶
func NewSessionManager ¶
NewSessionManager 如果是手动开启session EnableSession 那么也应该设置session的相应参数 ttl 超时时间,store 存储方式
func RefreshToken ¶
RefreshToken 刷新令牌 token 令牌 date 续期时间
func RestResultEnable ¶
func RestResultEnable() bool
func SetCookie ¶
func SetCookie(name, value string, ctx *Context, options ...*CookieOptions)
Types ¶
type Accounts ¶
type Accounts struct { UnAuthHandler AuthCheckHandler Users map[string]string }
type AuthCheckHandler ¶
type AuthCheckHandler func(ctx *Context)
AuthCheckHandler 定义一个没有认证的回调 DefaultAuthCheckHandler 默认回调 Accounts 逻辑完全由业务自己定义 业务将user加载到Accounts对象 业务设置没有检查到user的处理逻辑
type CommonHandler ¶
type CommonHandler struct { }
func (*CommonHandler) HandlerError ¶
func (handler *CommonHandler) HandlerError(ctx *Context, err *goerr.BizError)
type Context ¶
type Context struct { W response.Response R *http.Request // contains filtered or unexported fields }
func (*Context) BindJSON ¶
BindJSON curl -X POST -d '{"name":"wendell","age":28}' http://127.0.0.1:8888/user/bind/json
func (*Context) BindXml ¶
BindXml
@Example
type User struct { Name string `xml:"name"` Age int `xml:"age"` }
curl -X POST -d '<?xml version="1.0" encoding="UTF-8"?><root><age>25</age><name>juan</name></root>' -H 'Content-Type: application/xml' http://127.0.0.1:8888/user/bind/xml
func (*Context) ContentType ¶
func (*Context) DEBUG ¶
DEBUG INFO ERROR 日志打印 **************************提供框架使用框架日志打印方法start*****************************
func (*Context) DisableDecoderUseNumber ¶
func (c *Context) DisableDecoderUseNumber(fun func())
func (*Context) DisableStrictMatching ¶
func (c *Context) DisableStrictMatching(fun func())
func (*Context) EnableDecoderUseNumber ¶
func (c *Context) EnableDecoderUseNumber(fun func())
func (*Context) EnableStrictMatching ¶
func (c *Context) EnableStrictMatching(fun func())
func (*Context) ExpandJSON ¶
ExpandJSON 是否展开json
func (*Context) FileAttachment ¶
func (*Context) FileFromFS ¶
func (c *Context) FileFromFS(filepath string, fs http.FileSystem)
func (*Context) FormFile ¶
func (c *Context) FormFile(name string) (*multipart.FileHeader, error)
FormFile 返回第一个文件,一般业务就使用这一个 如果有多个文件可以使用 MultipartForm
func (*Context) GetBodyBool ¶ added in v1.0.1
GetBodyBool 获取bool类型参数
func (*Context) GetBodyFloat ¶ added in v1.0.1
GetBodyFloat 获取float类型参数
func (*Context) GetBodyInt ¶ added in v1.0.1
GetBodyInt 获取int类型参数
func (*Context) GetBodyInt64 ¶ added in v1.0.1
GetBodyInt64 获取int64类型参数
func (*Context) GetBodyLong ¶ added in v1.0.1
GetBodyLong 获取long类型参数
func (*Context) GetBodyString ¶ added in v1.0.1
GetBodyString 获取string类型的参数
func (*Context) GetFloat64 ¶
func (*Context) GetHandlerBizError ¶
func (c *Context) GetHandlerBizError() HandlerBizError
func (*Context) GetPostFormArray ¶
func (*Context) GetPostFormMap ¶
func (*Context) GetQueryArray ¶
GetQueryArray url.Values 是一个 map[string][]string 所以同一个key可以有多个值 提供一个获取数组的方法
func (*Context) GetQueryBool ¶ added in v1.0.1
GetQueryBool 获取bool类型参数
func (*Context) GetQueryFloat64 ¶ added in v1.0.1
GetQueryFloat64 获取float类型参数
func (*Context) GetQueryInt ¶ added in v1.0.1
GetQueryInt 获取int类型的参数
func (*Context) GetQueryInt64 ¶ added in v1.0.1
GetQueryInt64 获取int64类型参数
func (*Context) GetStringMapString ¶
func (*Context) GetStringMapStringSlice ¶
func (*Context) GetStringSlice ¶
func (*Context) HandlerError ¶
HandlerError SetHandlerBizError GetHandlerBizError Panic *****************************业务异常处理start***************************************
func (*Context) MultipartForm ¶
MultipartForm 通过 Form.file 拿到多个文件,是一个map对象
func (*Context) NewSession ¶
NewSession 创建一个session 一般只给登录请求使用,并且需要开启session支持 app.session.enable
func (*Context) PostForm ¶
PostForm application/x-www-form-urlencoded curl -X POST -d "sex=女&person[weight]=148&person[hight]=1.75" http://127.0.0.1:8888/user/add
func (*Context) PostFormArray ¶
func (*Context) PostFormBool ¶ added in v1.0.1
func (*Context) PostFormFloat64 ¶ added in v1.0.1
func (*Context) PostFormInt ¶ added in v1.0.1
PostFormInt 获取int类型参数
func (*Context) PostFormInt64 ¶ added in v1.0.1
func (*Context) Query ¶
Query 绝大部分业务不想处理bool,希望框架返回一个值就行啦 curl http://127.0.0.1:8888/user/add\?id=1001\&person%5Bname%5D=wendell\&person%5Bage%5D=21
func (*Context) QueryArray ¶
QueryArray 业务不需要ok bool参数
func (*Context) QueryMap ¶
QueryMap
请求 curl 127.0.0.1:8888/user/person[name]=wendell&person[age]=21 需要返回
{ "name":"wendell" "age": 21 }
func (*Context) QueryOrDefault ¶
QueryOrDefault 带有默认值的返回,不需要业务再去判空
func (*Context) RequestHeader ¶
RequestHeader *************头部操作***************************
func (*Context) Reset ¶
func (c *Context) Reset(w http.ResponseWriter, r *http.Request)
Reset 由于使用了对象池资源复用,复用的时候需要清理上一次缓存的数据
func (*Context) SaveUploadedFile ¶
func (c *Context) SaveUploadedFile(file *multipart.FileHeader, dst string) error
SaveUploadedFile 拿到文件后可以上传到指定的目录
func (*Context) SetCookie ¶
func (c *Context) SetCookie(name, value string, options ...*CookieOptions)
SetCookie 添加cookie到响应头
func (*Context) SetHandlerBizError ¶
func (c *Context) SetHandlerBizError(handler HandlerBizError)
func (*Context) SetSameSite ¶
SetSameSite with cookie SameSiteDefaultMode SameSite = iota + 1
SameSiteLaxMode SameSiteStrictMode SameSiteNoneMode
*****************************cookie start***************************************
type CookieOptions ¶
CookieOptions 可选项
func GetCookieOptionsByEnv ¶
func GetCookieOptionsByEnv() *CookieOptions
type Engine ¶
type Engine struct { FuncMap template.FuncMap // form表单上传文件的读取是是否全部加载到内存的阈值 MaxMultipartMemory int64 // 需要在应用启动的时候执行 PreRunFunc []func() // New出一个Engine的时候执行 PostNewFunc []func() // 应用启动完后的预热操作 WarmupFunc []func() // contains filtered or unexported fields }
func (*Engine) InitAclNodeList ¶
InitAclNodeList 初始化白名单列表 例如:fileName 文件名 ./file/acl.conf
func (*Engine) LoadHTMLFiles ¶
func (*Engine) LoadHTMLGlob ¶
LoadHTMLGlob 根据pattern规则一次性初始化多个模版 例如 file/**
func (*Engine) RegisterOnShutdown ¶
func (e *Engine) RegisterOnShutdown(hook func())
func (*Engine) RegisterPostNewFunc ¶
func (e *Engine) RegisterPostNewFunc(postNew func())
RegisterPostNewFunc New 之后执行
func (*Engine) RegisterPreRunFunc ¶
func (e *Engine) RegisterPreRunFunc(preRun func())
RegisterPreRunFunc 添加启动函数 Run 之前执行
func (*Engine) RegisterWarmupFunc ¶
func (e *Engine) RegisterWarmupFunc(warmup func())
RegisterWarmupFunc 添加预热执行函数
func (*Engine) RegistryServerPostProcessor ¶
func (e *Engine) RegistryServerPostProcessor(processor ServerPostProcessor)
func (*Engine) ServeHTTP ¶
func (e *Engine) ServeHTTP(w http.ResponseWriter, r *http.Request)
type Handler interface { ServeHTTP(ResponseWriter, *Request) }
ServeHTTP 实现Handler接口,是的Engine本身就是一个请求执行函数 目的是为了实现统一的入口 /** -> Engine
func (*Engine) SetFuncMap ¶
SetFuncMap FuncMap
func formatAsDate(t time.Time) string { year, month, day := t.Date() return fmt.Sprintf("%d/%02d/%02d", year, month, day) }
engine.SetFuncMap(template.FuncMap{ "formatAsDate": formatAsDate, })
func (*Engine) SetHTMLTemplate ¶
SetHTMLTemplate 初始化模版
func (*Engine) SetHandlerBizError ¶
func (e *Engine) SetHandlerBizError(handler HandlerBizError)
SetHandlerBizError 设置异常处理函数
func (*Engine) SetRouterHandler ¶
func (e *Engine) SetRouterHandler(handler RouterHandler)
SetRouterHandler 注册路由处理函数 只有当需要做一些其他中间件的时候可能用到
func (Engine) UseFront ¶
func (r Engine) UseFront(middlewares ...MiddlewareFunc)
type Filter ¶
type Filter struct { Order int // 排序,order较小的优先执行 Include string // 路径匹配,匹配到的才会执行 BeforeFunc and AfterFunc Exclude string // 排除某个路径,即使include包含也不会执行 BeforeFunc func(ctx *Context) bool AfterFunc func(ctx *Context) // contains filtered or unexported fields }
Filter 过滤器 在接收到请求执行beforeFunc 请求完成之后执行afterFunc
type FilterChain ¶
type FilterChain []*Filter
func (FilterChain) Len ¶
func (r FilterChain) Len() int
func (FilterChain) Swap ¶
func (r FilterChain) Swap(i, j int)
type HandlerBizError ¶
type HandlerFunc ¶
type HandlerFunc func(ctx *Context)
func Recovery ¶
func Recovery(next HandlerFunc) HandlerFunc
type JwtAuth ¶
type JwtAuth struct { UnAuthHandler AuthCheckHandler Include string Exclude string //key Key []byte }
func (*JwtAuth) ParseToken ¶
type JwtToken ¶
type JwtToken struct { Key []byte TimeOut time.Duration Alg string GetData func(ctx *Context) (map[string]any, error) }
func (*JwtToken) GetToken ¶
func (j *JwtToken) GetToken() MiddlewareFunc
GetToken 获取token,是一个前置中间件 应该使用在某一个路由中,比如/login 其中提供一个获取数据的函数,以获得数据生成token
type MiddlewareFunc ¶
type MiddlewareFunc func(handlerFunc HandlerFunc) HandlerFunc
type NothingHandler ¶
type NothingHandler struct { }
func (NothingHandler) HandlerError ¶
func (biz NothingHandler) HandlerError(ctx *Context, err *goerr.BizError)
type Response ¶
type Response struct { Writer http.ResponseWriter Committed bool // contains filtered or unexported fields }
func Wrap ¶
func Wrap(w http.ResponseWriter) (r *Response)
func (*Response) BufferString ¶
func (*Response) ClearBuffer ¶
func (r *Response) ClearBuffer()
func (*Response) ContentType ¶
func (*Response) Reset ¶
func (r *Response) Reset(w http.ResponseWriter)
func (*Response) Unwrap ¶
func (r *Response) Unwrap() http.ResponseWriter
func (*Response) WriteHeader ¶
func (*Response) WriteStatus ¶
func (*Response) WriteStatusNow ¶
func (r *Response) WriteStatusNow()
type RestResult ¶
RestResult 统一返回结果 {"code":200,"msg":"ok","data":""} 一般来说code 200 表示正常,其他表示异常
func RestFailed ¶ added in v1.0.1
func RestFailed(msg string) *RestResult
func RestSuccess ¶ added in v1.0.1
func RestSuccess(date any) *RestResult
type RouterHandler ¶
type RouterHandler func(ctx *Context)
RouterHandler 路由的真正处理逻辑,不同的逻辑可以实现不同的功能,例如代理转发
type ServerPostProcessor ¶
ServerPostProcessor Server的扩展
Source Files
¶
- banner.go
- basic_auth.go
- config.go
- constans.go
- context.go
- context_bind.go
- context_body_param_api.go
- context_form_param_api.go
- context_header.go
- context_query_param_api.go
- context_render.go
- cookie.go
- ctx.go
- engine.go
- error.go
- filter.go
- jwt_auth.go
- keys.go
- life_cycle.go
- log.go
- middleware.go
- processor.go
- recovery.go
- response.go
- rest_result.go
- restful.go
- router.go
- router_group.go
- session.go
- signal.go
- static.go
- timeout.go
- utils.go