This is an advanced API mock server built with Go. It supports CRUD operations and includes features like logging, CORS, rate limiting, input sanitization, JWT-based authentication, role-based access control (RBAC), and Swagger documentation.
- Go 1.22.5
- Docker (optional, for Docker support)
-
Clone the repository:
git clone https://github.com/your-repo/advanced-mock-server.git cd advanced-mock-server
-
Install dependencies:
go mod download
-
Run the server:
go run cmd/server/main.go
-
Build the Docker image:
docker build -t advanced-mock-server .
-
Run the Docker container:
docker run -p 8080:8080 advanced-mock-server
Swagger documentation is available at: http://localhost:8080/swagger/index.html
Use the /api/v1/auth
endpoint to obtain a JWT token. Use the token to access protected endpoints by adding it to the Authorization
header as Bearer <token>
.
Run the tests:
sh go test -v ./...
Configuration is managed through JSON files in the config
directory. Use environment variables to switch between configurations:
config.development.json
config.production.json