Documentation ¶
Index ¶
- Variables
- func All(path string, handlers ...fiber.Handler) fiber.Router
- func Delete(path string, handlers ...fiber.Handler) fiber.Router
- func Get(path string, handlers ...fiber.Handler) fiber.Router
- func GetClientIp(ctx *fiber.Ctx) string
- func Group(prefix string, needLogin, needRouterPermission bool) fiber.Router
- func InitWebApp(views fiber.Views) *webApp
- func Listener(ln net.Listener) error
- func NoNeed(ctx *fiber.Ctx) error
- func ParsePaginationInfoFromQuery(ctx *fiber.Ctx) (limit, offset int, orderBy string, err error)
- func Post(path string, handlers ...fiber.Handler) fiber.Router
- func Put(path string, handlers ...fiber.Handler) fiber.Router
- func RequireRouterPermission() fiber.Handler
- func Shutdown() error
- func StandardRouter(prefix string, add, update, delete, get, paginate fiber.Handler) fiber.Router
- func StandardVersionRouter(version, prefix string, add, update, delete, get, paginate fiber.Handler) fiber.Router
- func Start(addr string) error
- func Static(dir string)
- func Use(args ...interface{}) fiber.Router
Constants ¶
This section is empty.
Variables ¶
View Source
var Jwtware = jwtware.New(jwtware.Config{ SigningKey: []byte(constant.JWT_SECRET), ContextKey: constant.JWT_CONTEXT, SigningMethod: "HS256", TokenLookup: "header:Authorization,cookie:token", ErrorHandler: func(c *fiber.Ctx, err error) error { if err.Error() == "Missing or malformed JWT" { return c.Status(fiber.StatusBadRequest).SendString("无效的token信息") } else { return c.Status(fiber.StatusUnauthorized).SendString("Invalid or expired Authorization Token") } }, SuccessHandler: func(c *fiber.Ctx) error { jwtToken := c.Locals(constant.JWT_CONTEXT).(*jwt.Token) claims := jwtToken.Claims.(jwt.MapClaims) uid := claims["uid"].(string) sid := claims["sid"].(string) tenantId, tenantOk := claims["tenantId"].(string) if cache.Enabled() { rConn := cache.Get() defer rConn.Close() cachedUid, err := redis.String(rConn.Do("GET", cache.Prefix+":"+constant.AppSid+":"+sid)) if err != nil { if err != redis.ErrNil { logger.Error(err) } return c.Status(fiber.StatusUnauthorized).SendString("token信息失效") } if cachedUid != uid { logger.Error(err) return c.Status(fiber.StatusUnauthorized).SendString("token信息失效") } } c.Locals("userId", uid) if tenantOk { c.Locals("tenantId", tenantId) } return c.Next() }, })
Functions ¶
func GetClientIp ¶
func GetClientIp(ctx *fiber.Ctx) string
func InitWebApp ¶
func InitWebApp(views fiber.Views) *webApp
func RequireRouterPermission ¶
func RequireRouterPermission() fiber.Handler
func StandardRouter ¶
func StandardRouter(prefix string, add, update, delete, get, paginate fiber.Handler) fiber.Router
StandardRouter 标准路由,需要登录、校验权限
func StandardVersionRouter ¶
func StandardVersionRouter(version, prefix string, add, update, delete, get, paginate fiber.Handler) fiber.Router
Types ¶
This section is empty.
Click to show internal directories.
Click to hide internal directories.