http://localhost:8080/admin - Requires Authorization header and admin role
http://localhost:8080/api/users - API group with logging middleware
http://localhost:8080/v1/status - Version group with rate limiting
Endpoints
GET /public - Public endpoint with no middleware
GET /protected - Protected endpoint with authentication middleware
GET /admin - Admin endpoint with authentication and authorization middleware
GET /api/users - API endpoint with logging middleware
GET /v1/status - Versioned endpoint with rate limiting middleware
Testing Authentication
To test protected endpoints, include an Authorization header:
# This will work
curl -H "Authorization: Bearer token123" http://localhost:8080/protected
# This will fail with 401 Unauthorized
curl http://localhost:8080/protected
Middleware Examples
The example demonstrates several types of middleware:
Authentication Middleware: Checks for Authorization header
Authorization Middleware: Checks for admin role
Logging Middleware: Logs request details
Rate Limiting Middleware: Simulates rate limiting
Anonymous Middleware: Simple middleware without names
Each middleware is created with a descriptive name that helps with debugging and documentation.