context.go 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778
  1. package toolkit
  2. // ContextStringKey string key
  3. type ContextStringKey string
  4. const (
  5. // ContextKeyGateWayPrefix api gateway route path prefix
  6. ContextKeyGateWayPrefix ContextStringKey = `gateway_route_prefix`
  7. )
  8. // ContextKey int key
  9. type ContextKey int
  10. const (
  11. // ContextKeyRequestMethod is populated in the context by
  12. // PopulateRequestContext. Its value is r.Method.
  13. ContextKeyRequestMethod ContextKey = iota
  14. // ContextKeyRequestURI is populated in the context by
  15. // PopulateRequestContext. Its value is r.RequestURI.
  16. ContextKeyRequestURI
  17. // ContextKeyRequestPath is populated in the context by
  18. // PopulateRequestContext. Its value is r.URL.Path.
  19. ContextKeyRequestPath
  20. // ContextKeyRequestProto is populated in the context by
  21. // PopulateRequestContext. Its value is r.Proto.
  22. ContextKeyRequestProto
  23. // ContextKeyRequestHost is populated in the context by
  24. // PopulateRequestContext. Its value is r.Host.
  25. ContextKeyRequestHost
  26. // ContextKeyRequestRemoteAddr is populated in the context by
  27. // PopulateRequestContext. Its value is r.RemoteAddr.
  28. ContextKeyRequestRemoteAddr
  29. // ContextKeyRequestXForwardedFor is populated in the context by
  30. // PopulateRequestContext. Its value is r.Header.Get("X-Forwarded-For").
  31. ContextKeyRequestXForwardedFor
  32. // ContextKeyRequestXForwardedProto is populated in the context by
  33. // PopulateRequestContext. Its value is r.Header.Get("X-Forwarded-Proto").
  34. ContextKeyRequestXForwardedProto
  35. // ContextKeyRequestAuthorization is populated in the context by
  36. // PopulateRequestContext. Its value is r.Header.Get("Authorization").
  37. ContextKeyRequestAuthorization
  38. // ContextKeyRequestReferer is populated in the context by
  39. // PopulateRequestContext. Its value is r.Header.Get("Referer").
  40. ContextKeyRequestReferer
  41. // ContextKeyRequestUserAgent is populated in the context by
  42. // PopulateRequestContext. Its value is r.Header.Get("User-Agent").
  43. ContextKeyRequestUserAgent
  44. // ContextKeyRequestXRequestID is populated in the context by
  45. // PopulateRequestContext. Its value is r.Header.Get("X-Request-Id").
  46. ContextKeyRequestXRequestID
  47. // ContextKeyRequestAccept is populated in the context by
  48. // PopulateRequestContext. Its value is r.Header.Get("Accept").
  49. ContextKeyRequestAccept
  50. // ContextKeyResponseHeaders is populated in the context whenever a
  51. // ServerFinalizerFunc is specified. Its value is of type http.Header, and
  52. // is captured only once the entire response has been written.
  53. ContextKeyResponseHeaders
  54. // ContextKeyResponseSize is populated in the context whenever a
  55. // ServerFinalizerFunc is specified. Its value is of type int64.
  56. ContextKeyResponseSize
  57. // ContextKeyAccessToken auth access token
  58. ContextKeyAccessToken
  59. )