A simple Go-based microservice gateway that demonstrates authentication, external API integration, SFTP file handling, MongoDB connection, and Swagger documentation.
JWT-based authentication (/login)
Protected routes (/protected/*)
Fetching and saving LMS data from mock API to MongoDB
Reading file content from SFTP server
Rate limiting & logging middleware
Swagger API docs at /swagger/index.html
Golang (Gin framework)
MongoDB Atlas (Cloud database)
JWT for secure authentication
SFTP for file operations
Swagger for API documentation
api-hub/
βββ cmd/
β βββ main.go
βββ internal/
β βββ config/
β βββ handlers/
β βββ middleware/
β βββ models/
β βββ services/
βββ docs/
βββ go.mod
Clone the repo
Create .env file with:
JWT_SECRET=""
MONGO_URI=mongodb+srv://...your_atlas_uri
Run the app:
go run cmd/main.go
Open Swagger UI:
http://localhost:8080/swagger/index.html
Public
POST /login β Get JWT token
Protected (Require Bearer Token)
GET /protected/lms β Fetch and store LMS data
GET /protected/sftp β Download file from SFTP
π Authorize with JWT in Swagger
Call /login and copy the token
Click Authorize in Swagger
Paste: Bearer <your_token>
Now test protected endpoints
username: admin
password: 1234
LMS API uses a mock server
MongoDB connection is cloud-based
SFTP uses Rebex test server
MIT