req_interface_gen.go 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189
  1. // Code generated by ifacemaker; DO NOT EDIT.
  2. package fiber
  3. import (
  4. "mime/multipart"
  5. "github.com/valyala/fasthttp"
  6. )
  7. // Req is an interface for request-related Ctx methods.
  8. type Req interface {
  9. // Accepts checks if the specified extensions or content types are acceptable.
  10. Accepts(offers ...string) string
  11. // AcceptsCharsets checks if the specified charset is acceptable.
  12. AcceptsCharsets(offers ...string) string
  13. // AcceptsEncodings checks if the specified encoding is acceptable.
  14. AcceptsEncodings(offers ...string) string
  15. // AcceptsLanguages checks if the specified language is acceptable using
  16. // RFC 4647 Basic Filtering.
  17. AcceptsLanguages(offers ...string) string
  18. // AcceptsLanguagesExtended checks if the specified language is acceptable using
  19. // RFC 4647 Extended Filtering.
  20. AcceptsLanguagesExtended(offers ...string) string
  21. // App returns the *App reference to the instance of the Fiber application
  22. App() *App
  23. // BaseURL returns (protocol + host + base path).
  24. BaseURL() string
  25. // BodyRaw contains the raw body submitted in a POST request.
  26. // Returned value is only valid within the handler. Do not store any references.
  27. // Make copies or use the Immutable setting instead.
  28. BodyRaw() []byte
  29. //nolint:nonamedreturns // gocritic unnamedResult prefers naming decoded body, decode count, and error
  30. tryDecodeBodyInOrder(originalBody *[]byte, encodings []string) (body []byte, decodesRealized uint8, err error)
  31. // Body contains the raw body submitted in a POST request.
  32. // This method will decompress the body if the 'Content-Encoding' header is provided.
  33. // It returns the original (or decompressed) body data which is valid only within the handler.
  34. // Don't store direct references to the returned data.
  35. // If you need to keep the body's data later, make a copy or use the Immutable option.
  36. Body() []byte
  37. // RequestCtx returns *fasthttp.RequestCtx that carries a deadline
  38. // a cancellation signal, and other values across API boundaries.
  39. RequestCtx() *fasthttp.RequestCtx
  40. // Cookies are used for getting a cookie value by key.
  41. // Defaults to the empty string "" if the cookie doesn't exist.
  42. // If a default value is given, it will return that value if the cookie doesn't exist.
  43. // The returned value is only valid within the handler. Do not store any references.
  44. // Make copies or use the Immutable setting to use the value outside the Handler.
  45. Cookies(key string, defaultValue ...string) string
  46. // Request return the *fasthttp.Request object
  47. // This allows you to use all fasthttp request methods
  48. // https://godoc.org/github.com/valyala/fasthttp#Request
  49. Request() *fasthttp.Request
  50. // FormFile returns the first file by key from a MultipartForm.
  51. FormFile(key string) (*multipart.FileHeader, error)
  52. // FormValue returns the first value by key from a MultipartForm.
  53. // Search is performed in QueryArgs, PostArgs, MultipartForm and FormFile in this particular order.
  54. // Defaults to the empty string "" if the form value doesn't exist.
  55. // If a default value is given, it will return that value if the form value does not exist.
  56. // Returned value is only valid within the handler. Do not store any references.
  57. // Make copies or use the Immutable setting instead.
  58. FormValue(key string, defaultValue ...string) string
  59. // Fresh returns true when the response is still “fresh” in the client's cache,
  60. // otherwise false is returned to indicate that the client cache is now stale
  61. // and the full response should be sent.
  62. // When a client sends the Cache-Control: no-cache request header to indicate an end-to-end
  63. // reload request, this module will return false to make handling these requests transparent.
  64. // https://github.com/jshttp/fresh/blob/master/index.js#L33
  65. Fresh() bool
  66. // Get returns the HTTP request header specified by field.
  67. // Field names are case-insensitive
  68. // Returned value is only valid within the handler. Do not store any references.
  69. // Make copies or use the Immutable setting instead.
  70. Get(key string, defaultValue ...string) string
  71. // GetHeaders (a.k.a GetReqHeaders) returns the HTTP request headers.
  72. // Returned value is only valid within the handler. Do not store any references.
  73. // Make copies or use the Immutable setting instead.
  74. GetHeaders() map[string][]string
  75. // Host contains the host derived from the X-Forwarded-Host or Host HTTP header.
  76. // Returned value is only valid within the handler. Do not store any references.
  77. // In a network context, `Host` refers to the combination of a hostname and potentially a port number used for connecting,
  78. // while `Hostname` refers specifically to the name assigned to a device on a network, excluding any port information.
  79. // Example: URL: https://example.com:8080 -> Host: example.com:8080
  80. // Make copies or use the Immutable setting instead.
  81. // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy.
  82. Host() string
  83. // Hostname contains the hostname derived from the X-Forwarded-Host or Host HTTP header using the c.Host() method.
  84. // Returned value is only valid within the handler. Do not store any references.
  85. // Example: URL: https://example.com:8080 -> Hostname: example.com
  86. // Make copies or use the Immutable setting instead.
  87. // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy.
  88. Hostname() string
  89. // Port returns the remote port of the request.
  90. Port() string
  91. // IP returns the remote IP address of the request.
  92. // If ProxyHeader and IP Validation is configured, it will parse that header and return the first valid IP address.
  93. // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy.
  94. IP() string
  95. // extractIPsFromHeader will return a slice of IPs it found given a header name in the order they appear.
  96. // When IP validation is enabled, any invalid IPs will be omitted.
  97. extractIPsFromHeader(header string) []string
  98. // extractIPFromHeader will attempt to pull the real client IP from the given header when IP validation is enabled.
  99. // currently, it will return the first valid IP address in header.
  100. // when IP validation is disabled, it will simply return the value of the header without any inspection.
  101. // Implementation is almost the same as in extractIPsFromHeader, but without allocation of []string.
  102. extractIPFromHeader(header string) string
  103. // IPs returns a string slice of IP addresses specified in the X-Forwarded-For request header.
  104. // When IP validation is enabled, only valid IPs are returned.
  105. IPs() []string
  106. // Is returns the matching content type,
  107. // if the incoming request's Content-Type HTTP header field matches the MIME type specified by the type parameter
  108. Is(extension string) bool
  109. // Locals makes it possible to pass any values under keys scoped to the request
  110. // and therefore available to all following routes that match the request.
  111. //
  112. // All the values are removed from ctx after returning from the top
  113. // RequestHandler. Additionally, Close method is called on each value
  114. // implementing io.Closer before removing the value from ctx.
  115. Locals(key any, value ...any) any
  116. // Method returns the HTTP request method for the context, optionally overridden by the provided argument.
  117. // If no override is given or if the provided override is not a valid HTTP method, it returns the current method from the context.
  118. // Otherwise, it updates the context's method and returns the overridden method as a string.
  119. Method(override ...string) string
  120. // MultipartForm parse form entries from binary.
  121. // This returns a map[string][]string, so given a key, the value will be a string slice.
  122. MultipartForm() (*multipart.Form, error)
  123. // OriginalURL contains the original request URL.
  124. // Returned value is only valid within the handler. Do not store any references.
  125. // Make copies or use the Immutable setting to use the value outside the Handler.
  126. OriginalURL() string
  127. // Params is used to get the route parameters.
  128. // Defaults to empty string "" if the param doesn't exist.
  129. // If a default value is given, it will return that value if the param doesn't exist.
  130. // Returned value is only valid within the handler. Do not store any references.
  131. // Make copies or use the Immutable setting to use the value outside the Handler.
  132. Params(key string, defaultValue ...string) string
  133. // Scheme contains the request protocol string: http or https for TLS requests.
  134. // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy.
  135. Scheme() string
  136. // Protocol returns the HTTP protocol of request: HTTP/1.1 and HTTP/2.
  137. Protocol() string
  138. // Query returns the query string parameter in the url.
  139. // Defaults to empty string "" if the query doesn't exist.
  140. // If a default value is given, it will return that value if the query doesn't exist.
  141. // Returned value is only valid within the handler. Do not store any references.
  142. // Make copies or use the Immutable setting to use the value outside the Handler.
  143. Query(key string, defaultValue ...string) string
  144. // Queries returns a map of query parameters and their values.
  145. //
  146. // GET /?name=alex&wanna_cake=2&id=
  147. // Queries()["name"] == "alex"
  148. // Queries()["wanna_cake"] == "2"
  149. // Queries()["id"] == ""
  150. //
  151. // GET /?field1=value1&field1=value2&field2=value3
  152. // Queries()["field1"] == "value2"
  153. // Queries()["field2"] == "value3"
  154. //
  155. // GET /?list_a=1&list_a=2&list_a=3&list_b[]=1&list_b[]=2&list_b[]=3&list_c=1,2,3
  156. // Queries()["list_a"] == "3"
  157. // Queries()["list_b[]"] == "3"
  158. // Queries()["list_c"] == "1,2,3"
  159. //
  160. // GET /api/search?filters.author.name=John&filters.category.name=Technology&filters[customer][name]=Alice&filters[status]=pending
  161. // Queries()["filters.author.name"] == "John"
  162. // Queries()["filters.category.name"] == "Technology"
  163. // Queries()["filters[customer][name]"] == "Alice"
  164. // Queries()["filters[status]"] == "pending"
  165. Queries() map[string]string
  166. // Range returns a struct containing the type and a slice of ranges.
  167. Range(size int64) (Range, error)
  168. // Route returns the matched Route struct.
  169. Route() *Route
  170. // Subdomains returns a slice of subdomains from the host, excluding the last `offset` components.
  171. // If the offset is negative or exceeds the number of subdomains, an empty slice is returned.
  172. // If the offset is zero every label (no trimming) is returned.
  173. Subdomains(offset ...int) []string
  174. // Stale returns the inverse of Fresh, indicating if the client's cached response is considered stale.
  175. Stale() bool
  176. // IsProxyTrusted checks trustworthiness of remote ip.
  177. // If Config.TrustProxy false, it returns false.
  178. // IsProxyTrusted can check remote ip by proxy ranges and ip map.
  179. IsProxyTrusted() bool
  180. // IsFromLocal will return true if request came from local.
  181. IsFromLocal() bool
  182. // Release is a method to reset Req fields when to use ReleaseCtx()
  183. release()
  184. getBody() []byte
  185. }