This is a simple Go project that demonstrates user authentication and authorization using JSON Web Tokens (JWT).
Follow the instructions below to set up and run the project on your local machine.
Make sure you have the following tools installed:
-
Clone the repository:
git clone https://github.com/Mayejacob/go-jwt.git
-
Change to the project directory:
cd go-jwt-project
-
Install dependencies:
go mod tidy
-
Run the application:
go run main.go
Or alternatively:
go run .
The server will start on http://localhost:9000.
- Sign Up:
POST /users/signup
- Login:
POST /user/login
- All Users:
GET /users
- Get User by id:
GET /users/:user_id
mongo_uri: "mongodb://localhost:27017/your-database"
-
Endpoint:
POST /users/signup
-
Description: Sign up a new user.
-
Request Body:
{ "First_name": "maye", "Last_name": "Jayboss", "Password": "12345678", "email": "[email protected]", "Phone": "081690000", "User_type": "ADMIN" }
{ "First_name": "maye", "Last_name": "Jayboss", "Password": "12345678", "email": "[email protected]", "Phone": "081690000", "User_type": "USER" }
-
Endpoint:
POST /users/login
-
Description: login user.
-
Request Body:
{ "email": "[email protected]", "password": "your_password" }