http_utils.go
http_utils.go - Overview
- Overview
This file defines a utility function withCacheControl
to add a Cache-Control header to HTTP responses and sets a default cache age for autocomplete endpoints.
- Detailed Documentation
Variables
AutoCompleteCacheControlAge
- Purpose: Specifies the maximum age for the
Cache-Control
header for autocomplete endpoints. - Type:
time.Duration
- Value: 60 seconds.
- Purpose: Specifies the maximum age for the
Functions
withCacheControl
- Purpose: Wraps an
http.HandlerFunc
to add aCache-Control
header to the HTTP response. - Parameters:
maxAge
(time.Duration
): The maximum age in seconds for which the response should be cached.h
(http.HandlerFunc
): The HTTP handler function to wrap.
- Returns:
http.HandlerFunc
: A new HTTP handler function that sets theCache-Control
header before calling the original handler.
- Purpose: Wraps an
- Code Examples
None
- Clarity and Accuracy
The documentation is derived directly from the code and comments provided.
- Markdown & MDX Perfection
All markdown syntax is valid, and no MDX errors should occur.
- Edge Cases To Avoid Breaking MDX:
No edge cases were detected.
- Getting Started Relevance
Include in Getting Started: NO