Documentation ¶
Index ¶
- Variables
- func AddGobModels(models ...interface{})
- func AddLocaleAlias(locale, alias string)
- func AddTranslator(locale string, t *ut.Translator, alias ...string)
- func ErrorWrap(err *Error, keysAndValues ...interface{}) error
- func GetLanguage(c *gin.Context) string
- func NoRoute(c *gin.Context)
- func Validator() error
- func WriteJSON(w http.ResponseWriter, groups []string, obj interface{}) error
- type API
- func (a *API) Context(c *gin.Context) *Context
- func (a *API) Data(c *gin.Context, data interface{})
- func (a *API) Err(c *gin.Context, err error)
- func (a *API) ErrResp(c *gin.Context, err error)
- func (a *API) Groups(c *gin.Context, groups ...string)
- func (a *API) Handler(c *gin.Context, f func(resp *Response) error)
- func (a *API) HttpStatus(c *gin.Context, status int)
- func (a *API) Resp(c *gin.Context)
- func (a *API) Verifies(c *gin.Context, bindsAndFuncs ...interface{}) bool
- func (a *API) Verify(c *gin.Context, req interface{}) bool
- type Bind
- type BindFunc
- type Context
- type DiffGroupsJSON
- type ErrMsg
- type Error
- type PageOptional
- type Pageable
- type Response
- func (r *Response) Err() *Error
- func (r *Response) GetCode() int
- func (r *Response) GetData() interface{}
- func (r *Response) HttpStatus() int
- func (r *Response) Msg() interface{}
- func (r *Response) SetCode(code int)
- func (r *Response) SetData(data interface{})
- func (r *Response) SetErr(err *Error)
- func (r *Response) SetHttpStatus(status int)
- func (r *Response) SetMsg(msg interface{})
- func (r *Response) SetTime(timestamp int64)
- func (r *Response) Time() int64
- type Session
- func (s *Session) Delete(c *gin.Context, key interface{}) error
- func (s *Session) Get(c *gin.Context, key interface{}) interface{}
- func (s *Session) GetRoles(c *gin.Context) []string
- func (s *Session) GetToken(c *gin.Context) *auth.User
- func (s *Session) HasRole(c *gin.Context, role string) bool
- func (s *Session) Set(c *gin.Context, key interface{}, val interface{}) error
- func (s *Session) SetToken(c *gin.Context, id int64, state bool) error
Constants ¶
This section is empty.
Variables ¶
View Source
var ( StatusTooManyRequests = &Error{ Code: http.StatusTooManyRequests, Msg: ErrMsg{ "en": http.StatusText(http.StatusTooManyRequests), "zh": "请求太频繁,请稍后再试", }, } )
Functions ¶
func AddGobModels ¶
func AddGobModels(models ...interface{})
func AddLocaleAlias ¶ added in v0.2.0
func AddLocaleAlias(locale, alias string)
func AddTranslator ¶ added in v0.2.0
func AddTranslator(locale string, t *ut.Translator, alias ...string)
func GetLanguage ¶ added in v0.2.0
Types ¶
type Context ¶ added in v0.2.0
type Context struct {
// contains filtered or unexported fields
}
func NewContext ¶ added in v0.2.0
func NewContext() *Context
type DiffGroupsJSON ¶ added in v0.2.0
type DiffGroupsJSON struct { Groups []string Data interface{} }
func (DiffGroupsJSON) Render ¶ added in v0.2.0
func (d DiffGroupsJSON) Render(w http.ResponseWriter) (err error)
func (DiffGroupsJSON) WriteContentType ¶ added in v0.2.0
func (d DiffGroupsJSON) WriteContentType(w http.ResponseWriter)
type PageOptional ¶
type Response ¶
type Response struct { Code int `json:"code"` Data interface{} `json:"data"` Message interface{} `json:"msg"` Timestamp int64 `json:"timestamp"` // contains filtered or unexported fields }
func (*Response) HttpStatus ¶
func (*Response) SetHttpStatus ¶ added in v0.2.0
Source Files ¶
Click to show internal directories.
Click to hide internal directories.