Documentation ¶
Index ¶
- Constants
- func NewPaging() *glib.Paging
- func Start(args ...BootstrapFunc)
- type ActionHandler
- type BootstrapFunc
- type CommandLine
- type Cookie
- type CustomError
- type Filter
- type IActionFilter
- type IActionFilterList
- type IActionResult
- type IApp
- type IHttpAction
- type IHttpController
- type IHttpRouter
- type ISession
- type ISessionStore
- type IToken
- type PagingResult
- type RequestContext
- func (ctx *RequestContext) ClearSession()
- func (ctx *RequestContext) DeleteSession(name string)
- func (ctx *RequestContext) GetApp() IApp
- func (ctx *RequestContext) GetSession(name string) string
- func (ctx *RequestContext) GetToken() IToken
- func (ctx *RequestContext) IsAjax() bool
- func (ctx *RequestContext) SetSession(name, value string)
- func (ctx *RequestContext) ValidateSession(name, value string, args ...interface{}) bool
- type RequestHandler
- type Result
- type Token
- func (s *Token) GetPayload() *TokenPayload
- func (s *Token) GetToken() string
- func (s *Token) IsAuthenticated() bool
- func (s *Token) IsExpired() bool
- func (s *Token) IsValid() bool
- func (s *Token) ParseToken(token, userAgent string) error
- func (s *Token) SetAuthenticated(isAuthenticated bool)
- func (s *Token) SetExpire(expire int64)
- func (s *Token) SetPayload(payload *TokenPayload)
- type TokenPayload
Constants ¶
const ( DEBUG string = "debug" RELEASE string = "release" )
const ( COOKIE_SAME_SITE_STRICT string = "Strict" COOKIE_SAME_SITE_LAX string = "Lax" COOKIE_SAME_SITE_NONE string = "None" SESSION_IDENTITY string = "__webing_s__" SESSION_NAME_KEY string = "__session_name___" SESSION_STORE_KEY string = "__session_store__" )
const (
TOKEN_IDENTITY string = "__webing_t__"
)
================================================================================ * token * author: 美丽的地球啊 - mliu * ================================================================================
Variables ¶
This section is empty.
Functions ¶
func Start ¶
func Start(args ...BootstrapFunc)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * launch an app * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Types ¶
type ActionHandler ¶
type ActionHandler func(*RequestContext) IActionResult
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * Http请求动作接口 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type BootstrapFunc ¶
type BootstrapFunc func(IApp)
================================================================================ * webing web framework * author: 美丽的地球啊 - mliu * ================================================================================
type CommandLine ¶
type CommandLine struct { App string Host string Ports []int Db string IsSsl bool IsDebug bool IsTest bool IsOnline bool }
================================================================================ * webing web framework * author: 美丽的地球啊 - mliu * ================================================================================
type Cookie ¶
type Cookie struct { Name string `json:"name"` Path string `json:"path"` Domain string `json:"domain"` MaxAge int `json:"max_age"` SameSite string `json:"same_site"` IsHttpOnly bool `json:"is_http_only"` // Strict | Lax | None IsSecure bool `json:"is_secure"` }
================================================================================ * session * author: 美丽的地球啊 - mliu * ================================================================================
type CustomError ¶
================================================================================ * error * author: 美丽的地球啊 - mliu * ================================================================================
func NewCustomError ¶
func NewCustomError(msg string) *CustomError
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * instantiate custom error * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func NewError ¶
func NewError(code int32, msg string) *CustomError
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * instantiate custom error * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (CustomError) Error ¶
func (err CustomError) Error() string
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * error interface implementation * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type Filter ¶
type Filter struct {
Name string
}
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * action filter interface * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type IActionFilter ¶
type IActionFilter interface { Before(*RequestContext) IActionResult After(*RequestContext) }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * action filter interface * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type IActionFilterList ¶
type IActionFilterList []IActionFilter
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * action filter interface * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type IActionResult ¶
type IActionResult interface {
Render()
}
================================================================================ * result * author: 美丽的地球啊 - mliu * ================================================================================
type IApp ¶
type IApp interface { GetName() string GetCommandLine() *CommandLine GetBootstrap() BootstrapFunc Static(routerPath, filePath string) NoRoute(requestHandler RequestHandler) At(groupName string, actionFilters ...IActionFilter) IHttpAction Controller(groupName string, actionFilters ...IActionFilter) IHttpController Middleware(requestHandlers ...RequestHandler) }
================================================================================ * app * author: 美丽的地球啊 - mliu * ================================================================================
func NewApp ¶
func NewApp(name, templatePath string, bootstrapFunc BootstrapFunc) IApp
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * instantiating app * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type IHttpAction ¶
type IHttpAction interface { Get(path string, actionHandler ActionHandler, args ...interface{}) IHttpController Post(path string, actionHandler ActionHandler, args ...interface{}) IHttpController Delete(path string, actionHandler ActionHandler, args ...interface{}) IHttpController Patch(path string, actionHandler ActionHandler, args ...interface{}) IHttpController Options(path string, actionHandler ActionHandler, args ...interface{}) IHttpController Head(path string, actionHandler ActionHandler, args ...interface{}) IHttpController }
type IHttpController ¶
type IHttpController interface { IHttpAction GetName() string GetToken(ctx *RequestContext) IToken GetApp() IApp }
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * controller interface * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func NewController ¶
func NewController(name string, app IApp, actionFilters ...IActionFilter) IHttpController
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * instantiating the controller * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type IHttpRouter ¶
type IHttpRouter interface { Get(groupName, path string, requestHandler RequestHandler) IHttpRouter Post(groupName, path string, requestHandler RequestHandler) IHttpRouter Delete(groupName, path string, requestHandler RequestHandler) IHttpRouter Patch(groupName, path string, requestHandler RequestHandler) IHttpRouter Options(groupName, path string, requestHandler RequestHandler) IHttpRouter Head(groupName, path string, requestHandler RequestHandler) IHttpRouter NoRoute(requestHandler RequestHandler) }
================================================================================ * http router * author: 美丽的地球啊 - mliu * ================================================================================
func NewHttpRouter ¶
func NewHttpRouter(httpEngine *httpEngine) IHttpRouter
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * instantiating http router * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type ISession ¶
type ISession interface { //SessionId() string Get(key interface{}) interface{} Set(key interface{}, val interface{}) Values() map[interface{}]interface{} AddFlash(value interface{}, vars ...string) Flashes(vars ...string) []interface{} Save() error Delete(key interface{}) Clear() Options(Cookie) }
================================================================================ * session * author: 美丽的地球啊 - mliu * ================================================================================
type ISessionStore ¶
================================================================================ * session * author: 美丽的地球啊 - mliu * ================================================================================
type IToken ¶
type IToken interface { GetToken() string ParseToken(token, userAgent string) error GetPayload() *TokenPayload SetPayload(payload *TokenPayload) SetExpire(expire int64) SetAuthenticated(isAuthenticated bool) IsAuthenticated() bool IsExpired() bool IsValid() bool }
type PagingResult ¶
================================================================================ * result * author: 美丽的地球啊 - mliu * ================================================================================
type RequestContext ¶
================================================================================ * request context * author: 美丽的地球啊 - mliu * ================================================================================
func (*RequestContext) ClearSession ¶
func (ctx *RequestContext) ClearSession()
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * clear session * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*RequestContext) DeleteSession ¶
func (ctx *RequestContext) DeleteSession(name string)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * remove session value * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*RequestContext) GetApp ¶
func (ctx *RequestContext) GetApp() IApp
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * get app * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*RequestContext) GetSession ¶
func (ctx *RequestContext) GetSession(name string) string
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * get session value * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*RequestContext) GetToken ¶
func (ctx *RequestContext) GetToken() IToken
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * get token * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*RequestContext) IsAjax ¶
func (ctx *RequestContext) IsAjax() bool
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * is ajax request * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*RequestContext) SetSession ¶
func (ctx *RequestContext) SetSession(name, value string)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * set session value * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*RequestContext) ValidateSession ¶
func (ctx *RequestContext) ValidateSession(name, value string, args ...interface{}) bool
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * validate session value * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type RequestHandler ¶
type RequestHandler func(*RequestContext)
================================================================================ * request context * author: 美丽的地球啊 - mliu * ================================================================================
type Result ¶
type Result struct { Code int32 `json:"code"` Msg string `json:"msg"` Data interface{} `json:"data"` }
================================================================================ * result * author: 美丽的地球啊 - mliu * ================================================================================
type Token ¶
type Token struct {
// contains filtered or unexported fields
}
func NewToken ¶
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * instantiating token * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*Token) GetPayload ¶
func (s *Token) GetPayload() *TokenPayload
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * get payload * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*Token) GetToken ¶
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * get token string * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*Token) IsAuthenticated ¶
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * is certified * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*Token) IsExpired ¶
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * has token expired * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*Token) IsValid ¶
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * token signature is valid * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*Token) ParseToken ¶
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * parse token * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*Token) SetAuthenticated ¶
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * set is certified * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*Token) SetExpire ¶
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * set expire * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*Token) SetPayload ¶
func (s *Token) SetPayload(payload *TokenPayload)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * set payload * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
type TokenPayload ¶
type TokenPayload struct { Owner string `json:"iss"` //签发者 Domain string `json:"aud"` //接收域 AccountId string `json:"account_id"` //账号id AccountName string `json:"account_name"` //账号名 UserId string `json:"sub"` //用户id Nickname string `json:"nickname"` //用户昵称 Avatar string `json:"avatar"` //用户图像 Roles []string `json:"roles"` //角色名集合 UserAgent string `json:"ua"` //客户端代理数据 Extend map[string]interface{} `json:"extend"` //扩展数据 IsAuthenticated bool `json:"is_authenticated"` //是否已验证 Start int64 `json:"iat"` //签发时间(距离1970-1-1的秒数) Expire int64 `json:"exp"` //过期时间(距离1970-1-1的秒数) }
func (*TokenPayload) AccountIdInt64 ¶ added in v0.1.7
func (s *TokenPayload) AccountIdInt64() int64
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * AccountId string to AccountId int64 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*TokenPayload) Deserialize ¶
func (s *TokenPayload) Deserialize(payload string) error
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * TokenPayload json deserialization * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*TokenPayload) Serialize ¶
func (s *TokenPayload) Serialize() (string, error)
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * TokenPayload json serialization * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
func (*TokenPayload) UserIdInt64 ¶
func (s *TokenPayload) UserIdInt64() int64
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ * UserId string to UserId int64 * ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++