This repository contains a Go microservice using the Gin framework and MongoDB. The microservice provides basic CRUD operations for managing users and includes several controllers for various functionalities.
Invoke-RestMethod
Clone the repository to your local machine:
git clone https://github.com/anassajja/Training_Session_Microservice.git
cd Training_Session_Microservice
Create a .env
file in the root directory with the following content:
MONGODB_URI=mongodb://localhost:27017
Run the following command to install the required Go packages:
go mod tidy
Start the server by running:
go run cmd/main.go
The server should now be running on http://localhost:8080.
Recommended to test API endpoints using Postman tool.
Retrieve a list of users:
curl -X GET http://localhost:8080/users
Or in PowerShell:
Invoke-RestMethod -Method Get -Uri http://localhost:8080/users
Create a new user:
curl -X POST http://localhost:8080/users \
-H "Content-Type: application/json" \
-d '{"name": "John Doe", "email": "[email protected]"}'
Or in PowerShell:
$body = @{
name = "John Doe"
email = "[email protected]"
}
Invoke-RestMethod -Method Post -Uri http://localhost:8080/users -Body ($body | ConvertTo-Json) -ContentType "application/json"
SessionController
Scheduling Sessions:
Getting Sessions:
Managing Sessions:
UserController
User Enrollment:
User Invitations:
User Cancellation:
Feedback:
CoachController
Coach Management:
Coach Role Assignment:
Coach Session Creation:
BusinessController
Business Management:
Business Dashboard:
Business Session Creation:
ReservationController
NotificationController
Session Notifications:
User Notifications:
FeedbackController
Session Feedback:
Coach Feedback:
QRCodeController
QR Code Generation:
QR Code Validation:
To run the tests for the project, use the following command:
go test ./...
This command will execute all tests in your project. Make sure to create test files following Go’s testing conventions (*_test.go
) to ensure coverage.
.env
file.go test ./...
.By including these updates, your README.md
will provide clear instructions for setting up, running, and testing your Go microservice project.