EQuimper / go-fiber-jwt-tutorial

A tutorial where we learn about using the Go Fiber jwt middleware
https://youtu.be/ejEizICXm9w
11 stars 6 forks source link

update example for v2 #1

Open abhijitgujar86 opened 4 years ago

abhijitgujar86 commented 4 years ago

Fiber have moved to v2 . there are many breaking changes . I think it will be good to have updated examples. adn this will help all.

github.com/gofiber/fiber/v2

EQuimper commented 4 years ago

@abhijitgujar86 good idea I will do a video with the change

OmkoBass commented 3 years ago

@abhijitgujar86

For the auth function

func auth() fiber.Handler {
    return jwtware.New(jwtware.Config{
        ErrorHandler: func(ctx *fiber.Ctx, err error) error {
            return ctx.Status(fiber.StatusUnauthorized).JSON(fiber.Map{
                "error": "Unauthorized",
            })
        },
        SigningKey: []byte(JwtSecretKey),
    })
}

if you can't figure what you should place, your IDE can help you with the types