configuration.go 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596
  1. package context
  2. // ConfigurationReadOnly can be implemented
  3. // by Configuration, it's being used inside the Context.
  4. // All methods that it contains should be "safe" to be called by the context
  5. // at "serve time". A configuration field may be missing when it's not
  6. // safe or its useless to be called from a request handler.
  7. type ConfigurationReadOnly interface {
  8. // GetVHost returns the non-exported vhost config field.
  9. //
  10. // If original addr ended with :443 or :80, it will return the host without the port.
  11. // If original addr was :https or :http, it will return localhost.
  12. // If original addr was 0.0.0.0, it will return localhost.
  13. GetVHost() string
  14. // GetDisablePathCorrection returns the configuration.DisablePathCorrection,
  15. // DisablePathCorrection corrects and redirects the requested path to the registered path
  16. // for example, if /home/ path is requested but no handler for this Route found,
  17. // then the Router checks if /home handler exists, if yes,
  18. // (permant)redirects the client to the correct path /home.
  19. GetDisablePathCorrection() bool
  20. // GetEnablePathEscape is the configuration.EnablePathEscape,
  21. // returns true when its escapes the path, the named parameters (if any).
  22. GetEnablePathEscape() bool
  23. // GetEnableOptimizations returns whether
  24. // the application has performance optimizations enabled.
  25. GetEnableOptimizations() bool
  26. // GetFireMethodNotAllowed returns the configuration.FireMethodNotAllowed.
  27. GetFireMethodNotAllowed() bool
  28. // GetDisableBodyConsumptionOnUnmarshal returns the configuration.GetDisableBodyConsumptionOnUnmarshal,
  29. // manages the reading behavior of the context's body readers/binders.
  30. // If returns true then the body consumption by the `context.UnmarshalBody/ReadJSON/ReadXML`
  31. // is disabled.
  32. //
  33. // By-default io.ReadAll` is used to read the body from the `context.Request.Body which is an `io.ReadCloser`,
  34. // if this field setted to true then a new buffer will be created to read from and the request body.
  35. // The body will not be changed and existing data before the
  36. // context.UnmarshalBody/ReadJSON/ReadXML will be not consumed.
  37. GetDisableBodyConsumptionOnUnmarshal() bool
  38. // GetDisableAutoFireStatusCode returns the configuration.DisableAutoFireStatusCode.
  39. // Returns true when the http error status code handler automatic execution turned off.
  40. GetDisableAutoFireStatusCode() bool
  41. // GetTimeFormat returns the configuration.TimeFormat,
  42. // format for any kind of datetime parsing.
  43. GetTimeFormat() string
  44. // GetCharset returns the configuration.Charset,
  45. // the character encoding for various rendering
  46. // used for templates and the rest of the responses.
  47. GetCharset() string
  48. // GetPostMaxMemory returns the maximum configured post data size
  49. // that a client can send to the server, this differs
  50. // from the overral request body size which can be modified
  51. // by the `context#SetMaxRequestBodySize` or `iris#LimitRequestBodySize`.
  52. //
  53. // Defaults to 32MB or 32 << 20 if you prefer.
  54. GetPostMaxMemory() int64
  55. // GetTranslateLanguageContextKey returns the configuration's TranslateFunctionContextKey value,
  56. // used for i18n.
  57. GetTranslateFunctionContextKey() string
  58. // GetTranslateLanguageContextKey returns the configuration's TranslateLanguageContextKey value,
  59. // used for i18n.
  60. GetTranslateLanguageContextKey() string
  61. // GetViewLayoutContextKey returns the key of the context's user values' key
  62. // which is being used to set the template
  63. // layout from a middleware or the main handler.
  64. // Overrides the parent's or the configuration's.
  65. GetViewLayoutContextKey() string
  66. // GetViewDataContextKey returns the key of the context's user values' key
  67. // which is being used to set the template
  68. // binding data from a middleware or the main handler.
  69. GetViewDataContextKey() string
  70. // GetRemoteAddrHeaders returns the allowed request headers names
  71. // that can be valid to parse the client's IP based on.
  72. //
  73. // Defaults to:
  74. // "X-Real-Ip": true,
  75. // "X-Forwarded-For": true,
  76. // "CF-Connecting-IP": false
  77. //
  78. // Look `context.RemoteAddr()` for more.
  79. GetRemoteAddrHeaders() map[string]bool
  80. // GetOther returns the configuration.Other map.
  81. GetOther() map[string]interface{}
  82. }