Header Parameters
Learn how to work with HTTP headers in moclojer. Access and use request headers in dynamic responses (Authorization, User-Agent, etc).
What Are HTTP Headers?
GET /api/users HTTP/1.1
Host: localhost:8000
Content-Type: application/json
Authorization: Bearer token123
User-Agent: curl/7.64.1
Accept: application/jsonWhy Use Headers?
Accessing Request Headers
Syntax: {{header-params.HeaderName}}
{{header-params.HeaderName}}Common Headers
1. Authorization (Authentication)
2. User-Agent (Client)
3. Content-Type
4. Accept (Content Negotiation)
5. Custom Headers (X-*)
Defining Response Headers
Simple Headers
Dynamic Headers
CORS Headers
Cache Headers
Practical Use Cases
1. Bearer Token Authentication
2. API Versioning via Header
3. Request Tracking
4. Multi-Tenant API
5. Rate Limiting Headers
6. Content Negotiation
Combining Parameters
Headers + Path + Query + Body
Headers Case-Insensitive
Standard Headers vs Custom
Standard Headers (Avoid X- prefix)
Custom Headers (Use specific prefix)
Best Practices
β
Do
β Avoid
Troubleshooting
Problem: Header is not replaced
Problem: Custom header doesn't appear
Problem: CORS error
Important Headers
Header
Usage
Example
Next Steps
See Also
Last updated
Was this helpful?