Documentation ¶
Index ¶
- Variables
- func ErrAlreadyExist(field string, err error) errorResponseType
- func ErrForbiden() errorResponseType
- func ErrNotFound(field string, err error) errorResponseType
- func ErrNotImplemented(fnName string) errorResponseType
- func ErrUnauthorized(err error) errorResponseType
- func ErrValidation(message string, err error) errorResponseType
- func MakeJWT(cfg JWT, id uint, username string, role Role, perms ...Permission) (string, error)
- func PermissionExist(perm Permission, perms []Permission) bool
- type Claims
- type Config
- type Context
- type Controller
- func (c Controller) Authorize(f fnAction, r Role, perms ...Permission) fnAction
- func (c Controller) DecodeJson(ctx *Context, v interface{}) error
- func (c Controller) Handle(f fnAction) fasthttp.RequestHandler
- func (c Controller) HandleW(f fnAction) fasthttp.RequestHandler
- func (c Controller) Response(ctx *Context, statusCode int) error
- func (c Controller) ResponseWithJson(ctx *Context, statusCode int, v interface{}) error
- func (c Controller) SetJWT(ctx *Context, tkn string)
- func (c Controller) View(ctx *Context, buff *bytes.Buffer) error
- type ErrorResponseType
- type Identify
- type JWT
- type Permission
- type RefreshToken
- type Role
- type SessionConfig
Constants ¶
This section is empty.
Variables ¶
View Source
var JwtAlgorithms = map[string]*jwt.SigningMethodHMAC{ "HS256": jwt.SigningMethodHS256, "HS384": jwt.SigningMethodHS384, "HS512": jwt.SigningMethodHS512, }
Functions ¶
func ErrAlreadyExist ¶ added in v0.2.0
func ErrForbiden ¶
func ErrForbiden() errorResponseType
func ErrNotFound ¶
func ErrNotImplemented ¶
func ErrNotImplemented(fnName string) errorResponseType
func ErrUnauthorized ¶
func ErrUnauthorized(err error) errorResponseType
func ErrValidation ¶
func PermissionExist ¶
func PermissionExist(perm Permission, perms []Permission) bool
Types ¶
type Claims ¶
type Claims struct { ID uint `json:"id"` Username string `json:"username"` Role Role `json:"role"` Permissions []Permission `json:"permissions"` jwt.StandardClaims }
type Config ¶
type Config struct { DevMode bool SecretKey string JWT JWT HTTPPort int DbSession SessionConfig }
type Context ¶
type Context struct { *fasthttp.RequestCtx Identify *Identify }
func (Context) ReadUserIP ¶
func (*Context) WithIdentify ¶
type Controller ¶
type Controller struct { Log logrus.FieldLogger Config Config }
func NewController ¶
func NewController(l logrus.FieldLogger, c Config) Controller
func (Controller) Authorize ¶
func (c Controller) Authorize(f fnAction, r Role, perms ...Permission) fnAction
func (Controller) DecodeJson ¶
func (c Controller) DecodeJson(ctx *Context, v interface{}) error
func (Controller) Handle ¶
func (c Controller) Handle(f fnAction) fasthttp.RequestHandler
func (Controller) HandleW ¶ added in v0.3.8
func (c Controller) HandleW(f fnAction) fasthttp.RequestHandler
TODO: fix error handling
func (Controller) Response ¶ added in v0.3.0
func (c Controller) Response(ctx *Context, statusCode int) error
func (Controller) ResponseWithJson ¶ added in v0.3.13
func (c Controller) ResponseWithJson(ctx *Context, statusCode int, v interface{}) error
func (Controller) SetJWT ¶
func (c Controller) SetJWT(ctx *Context, tkn string)
type ErrorResponseType ¶
type JWT ¶
type JWT struct { Secret []byte Algorithm jwt.SigningMethod MaxAge int64 HTTPOnly bool RefreshToken RefreshToken Path string Secure bool }
type RefreshToken ¶
type SessionConfig ¶
type SessionConfig struct { Driver string Host string Port string User string Password string DBName string Schema string TestDBName string AdminDBName string SslMode string TimeZone string MigrationsPath string MigrationsTable string }
func (SessionConfig) AdminDsn ¶ added in v0.3.14
func (s SessionConfig) AdminDsn() string
func (SessionConfig) Dsn ¶
func (s SessionConfig) Dsn() string
func (SessionConfig) DsnWithSchema ¶
func (s SessionConfig) DsnWithSchema() string
Click to show internal directories.
Click to hide internal directories.