Documentation ¶
Index ¶
- Constants
- func ClientIP(next http.Handler) http.Handler
- func HealthCheck(w http.ResponseWriter, _ *http.Request)
- func Logger(log *logrus.Entry) func(http.Handler) http.Handler
- func ParseClientVersion(next http.Handler) http.Handler
- func StripPrefix(prefix string) func(http.Handler) http.Handler
- type ClientVersion
Constants ¶
const ( ClientPlatformIOS = "ios" ClientPlatformAndroid = "android" )
const ClientIPHeader = `Infra-Client-Ip`
ClientIPHeader is the customer header, set by our network edge, that is expected to be the clients real IP address when X-Forwarded-For cannot be trusted.
Variables ¶
This section is empty.
Functions ¶
func ClientIP ¶
ClientIP respects the infra-client-ip header containing the clients real IP address.
func HealthCheck ¶
func HealthCheck(w http.ResponseWriter, _ *http.Request)
func Logger ¶
Logger returns a middleware handler that wraps subsequent middleware/handlers and logs request information AFTER the request has completed. It also injects a request-scoped logger on the context which can be set, read and updated using clog lib
Included fields:
- Request ID (request_id)
- HTTP Method (http_method)
- HTTP Path (http_path)
- HTTP Protocol Version (http_proto)
- Remote Address (http_remote_addr)
- User Agent Header (http_user_agent)
- Referer Header (http_referer)
- Duration with unit (http_duration)
- Duration in microseconds (http_duration_us)
- HTTP Status Code (http_status)
- Response in bytes (http_response_bytes)
- Client Version header (http_client_version)
- User Agent header (http_user_agent)
func ParseClientVersion ¶
ParseClientVersion attempts to parse the infra-client-version HTTP header and add it as a struct to the context
Types ¶
type ClientVersion ¶
ClientVersion represents a parsed client version header string
func GetClientVersion ¶
func GetClientVersion(r *http.Request) *ClientVersion
GetClientVersion retrieves the parsed version from a request
func GetClientVersionContext ¶
func GetClientVersionContext(ctx context.Context) *ClientVersion
GetClientVersionContext retrieves the parsed version from a request context