Skip to content

zahidcakici/go-fiber-jwt

Repository files navigation

Go Fiber JWT Example

This repository contains an example project demonstrating how to use JWT (JSON Web Tokens) with the Go Fiber web framework.

Project Structure

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

Getting Started

Prerequisites

  • Go 1.16 or higher
  • A configured Go environment

Installation

  1. Clone the repository:

    git clone https://github.com/yourusername/go-fiber-jwt-example.git
    cd go-fiber-jwt-example
  2. Install dependencies:

    go mod tidy

Running the Application

  1. Start the application:

    go run main.go
  2. The server will start on http://localhost:3000.

Project Structure

  • controller/
    • auth.go: Contains the authentication handlers.
    • book.go: Contains the book handlers.
  • 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 the GeneratePassword and ComparePassword function.
    • token.go: Contains the GenerateToken and VerifyToken function.
  • main.go: The entry point of the application.

License

This project is licensed under the MIT License. See the LICENSE file for details.

About

This is a codebase example for Go Fiber

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published