This repository contains an example project demonstrating how to use JWT (JSON Web Tokens) with the Go Fiber web framework.
go-fiber-jwt-example/
├── controller/
│ ├── auth.go
│ ├── book.go
├── database/
│ ├── db.go
├── middleware/
│ ├── auth.go
├── model/
│ ├── book.go
│ ├── user.go
├── router/
│ ├── router.go
├── utils/
│ ├── password.go
│ ├── token.go
└── main.go
- Go 1.16 or higher
- A configured Go environment
-
Clone the repository:
git clone https://github.com/yourusername/go-fiber-jwt-example.git cd go-fiber-jwt-example
-
Install dependencies:
go mod tidy
-
Start the application:
go run main.go
-
The server will start on
http://localhost:3000
.
controller/
database/
: Contains the database connection logic.middleware/
jwt.go
: Ensures authenticated access to routes by validating and decoding JSON Web Tokens (JWT).
model/
: Contains the data models.router/
: Contains the application routes.utils/
password.go
: Contains theGeneratePassword
andComparePassword
function.token.go
: Contains theGenerateToken
andVerifyToken
function.
main.go
: The entry point of the application.
This project is licensed under the MIT License. See the LICENSE file for details.