ctx_interface_gen.go 26 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489
  1. // Code generated by ifacemaker; DO NOT EDIT.
  2. package fiber
  3. import (
  4. "bufio"
  5. "context"
  6. "crypto/tls"
  7. "io"
  8. "mime/multipart"
  9. "time"
  10. "github.com/valyala/fasthttp"
  11. )
  12. // Ctx represents the Context which hold the HTTP request and response.
  13. // It has methods for the request query string, parameters, body, HTTP headers and so on.
  14. type Ctx interface {
  15. // App returns the *App reference to the instance of the Fiber application
  16. App() *App
  17. // BaseURL returns (protocol + host + base path).
  18. BaseURL() string
  19. // RequestCtx returns *fasthttp.RequestCtx that carries a deadline
  20. // a cancellation signal, and other values across API boundaries.
  21. RequestCtx() *fasthttp.RequestCtx
  22. // Context returns a context implementation that was set by
  23. // user earlier or returns a non-nil, empty context, if it was not set earlier.
  24. Context() context.Context
  25. // SetContext sets a context implementation by user.
  26. SetContext(ctx context.Context)
  27. // Deadline returns the time when work done on behalf of this context
  28. // should be canceled. Deadline returns ok==false when no deadline is
  29. // set. Successive calls to Deadline return the same results.
  30. //
  31. // Due to current limitations in how fasthttp works, Deadline operates as a nop.
  32. // See: https://github.com/valyala/fasthttp/issues/965#issuecomment-777268945
  33. Deadline() (time.Time, bool)
  34. // Done returns a channel that's closed when work done on behalf of this
  35. // context should be canceled. Done may return nil if this context can
  36. // never be canceled. Successive calls to Done return the same value.
  37. // The close of the Done channel may happen asynchronously,
  38. // after the cancel function returns.
  39. //
  40. // Due to current limitations in how fasthttp works, Done operates as a nop.
  41. // See: https://github.com/valyala/fasthttp/issues/965#issuecomment-777268945
  42. Done() <-chan struct{}
  43. // Err mirrors context.Err, returning nil until cancellation and then the terminal error value.
  44. //
  45. // Due to current limitations in how fasthttp works, Err operates as a nop.
  46. // See: https://github.com/valyala/fasthttp/issues/965#issuecomment-777268945
  47. Err() error
  48. // Request return the *fasthttp.Request object
  49. // This allows you to use all fasthttp request methods
  50. // https://godoc.org/github.com/valyala/fasthttp#Request
  51. // Returns nil if the context has been released.
  52. Request() *fasthttp.Request
  53. // Response return the *fasthttp.Response object
  54. // This allows you to use all fasthttp response methods
  55. // https://godoc.org/github.com/valyala/fasthttp#Response
  56. // Returns nil if the context has been released.
  57. Response() *fasthttp.Response
  58. // Get returns the HTTP request header specified by field.
  59. // Field names are case-insensitive
  60. // Returned value is only valid within the handler. Do not store any references.
  61. // Make copies or use the Immutable setting instead.
  62. Get(key string, defaultValue ...string) string
  63. // GetHeaders returns the HTTP request headers.
  64. // Returned value is only valid within the handler. Do not store any references.
  65. // Make copies or use the Immutable setting instead.
  66. GetHeaders() map[string][]string
  67. // GetReqHeaders returns the HTTP request headers.
  68. // Returned value is only valid within the handler. Do not store any references.
  69. // Make copies or use the Immutable setting instead.
  70. GetReqHeaders() map[string][]string
  71. // GetRespHeader returns the HTTP response header specified by field.
  72. // Field names are case-insensitive
  73. // Returned value is only valid within the handler. Do not store any references.
  74. // Make copies or use the Immutable setting instead.
  75. GetRespHeader(key string, defaultValue ...string) string
  76. // GetRespHeaders returns the HTTP response headers.
  77. // Returned value is only valid within the handler. Do not store any references.
  78. // Make copies or use the Immutable setting instead.
  79. GetRespHeaders() map[string][]string
  80. // ClientHelloInfo return CHI from context
  81. ClientHelloInfo() *tls.ClientHelloInfo
  82. // Next executes the next method in the stack that matches the current route.
  83. Next() error
  84. // RestartRouting instead of going to the next handler. This may be useful after
  85. // changing the request path. Note that handlers might be executed again.
  86. RestartRouting() error
  87. setHandlerCtx(ctx CustomCtx)
  88. // OriginalURL contains the original request URL.
  89. // Returned value is only valid within the handler. Do not store any references.
  90. // Make copies or use the Immutable setting to use the value outside the Handler.
  91. OriginalURL() string
  92. // Path returns the path part of the request URL.
  93. // Optionally, you could override the path.
  94. // Make copies or use the Immutable setting to use the value outside the Handler.
  95. Path(override ...string) string
  96. // RequestID returns the request identifier from the response header or request header.
  97. RequestID() string
  98. // Req returns a convenience type whose API is limited to operations
  99. // on the incoming request.
  100. Req() Req
  101. // Res returns a convenience type whose API is limited to operations
  102. // on the outgoing response.
  103. Res() Res
  104. // Redirect returns the Redirect reference.
  105. // Use Redirect().Status() to set custom redirection status code.
  106. // If status is not specified, status defaults to 303 See Other.
  107. // You can use Redirect().To(), Redirect().Route() and Redirect().Back() for redirection.
  108. Redirect() *Redirect
  109. // ViewBind Add vars to default view var map binding to template engine.
  110. // Variables are read by the Render method and may be overwritten.
  111. ViewBind(vars Map) error
  112. // Route returns the matched Route struct.
  113. Route() *Route
  114. // FullPath returns the matched route path, including any group prefixes.
  115. FullPath() string
  116. // Matched returns true if the current request path was matched by the router.
  117. Matched() bool
  118. // IsMiddleware returns true if the current request handler was registered as middleware.
  119. IsMiddleware() bool
  120. // HasBody returns true if the request declares a body via Content-Length, Transfer-Encoding, or already buffered payload data.
  121. HasBody() bool
  122. // OverrideParam overwrites a route parameter value by name.
  123. // If the parameter name does not exist in the route, this method does nothing.
  124. OverrideParam(name, value string)
  125. // IsWebSocket returns true if the request includes a WebSocket upgrade handshake.
  126. IsWebSocket() bool
  127. // IsPreflight returns true if the request is a CORS preflight.
  128. IsPreflight() bool
  129. // SaveFile saves any multipart file to disk.
  130. SaveFile(fileheader *multipart.FileHeader, path string) error
  131. // SaveFileToStorage saves any multipart file to an external storage system.
  132. SaveFileToStorage(fileheader *multipart.FileHeader, path string, storage Storage) error
  133. // Secure returns whether a secure connection was established.
  134. Secure() bool
  135. // Status sets the HTTP status for the response.
  136. // This method is chainable.
  137. Status(status int) Ctx
  138. // String returns unique string representation of the ctx.
  139. //
  140. // The returned value may be useful for logging.
  141. String() string
  142. // Value makes it possible to retrieve values (Locals) under keys scoped to the request
  143. // and therefore available to all following routes that match the request. If the context
  144. // has been released and c.fasthttp is nil (for example, after ReleaseCtx), Value returns nil.
  145. Value(key any) any
  146. // XHR returns a Boolean property, that is true, if the request's X-Requested-With header field is XMLHttpRequest,
  147. // indicating that the request was issued by a client library (such as jQuery).
  148. XHR() bool
  149. // configDependentPaths set paths for route recognition and prepared paths for the user,
  150. // here the features for caseSensitive, decoded paths, strict paths are evaluated
  151. configDependentPaths()
  152. // Reset is a method to reset context fields by given request when to use server handlers.
  153. Reset(fctx *fasthttp.RequestCtx)
  154. // release is a method to reset context fields when to use ReleaseCtx()
  155. release()
  156. // Abandon marks this context as abandoned. An abandoned context will not be
  157. // returned to the pool when ReleaseCtx is called.
  158. //
  159. // This is used by the timeout middleware to return immediately while the
  160. // handler goroutine continues using the context safely.
  161. //
  162. // Only call ForceRelease after Abandon if you can guarantee no other goroutine
  163. // (including Fiber's requestHandler and ErrorHandler) will touch the context.
  164. // The timeout middleware intentionally does NOT call ForceRelease to avoid
  165. // races, which means timed-out requests leak their contexts until a safe
  166. // reclamation strategy exists.
  167. Abandon()
  168. // IsAbandoned returns true if Abandon() was called on this context.
  169. IsAbandoned() bool
  170. // ForceRelease releases an abandoned context back to the pool.
  171. // This MUST only be called after all goroutines (including requestHandler and
  172. // ErrorHandler) have completely finished using this context. Calling it while
  173. // any goroutine is still running causes races.
  174. ForceRelease()
  175. renderExtensions(bind any)
  176. // Bind You can bind body, cookie, headers etc. into the map, map slice, struct easily by using Binding method.
  177. // It gives custom binding support, detailed binding options and more.
  178. // Replacement of: BodyParser, ParamsParser, GetReqHeaders, GetRespHeaders, AllParams, QueryParser, ReqHeaderParser
  179. Bind() *Bind
  180. // Methods to use with next stack.
  181. getMethodInt() int
  182. getIndexRoute() int
  183. getTreePathHash() int
  184. getDetectionPath() string
  185. getValues() *[maxParams]string
  186. getMatched() bool
  187. getSkipNonUseRoutes() bool
  188. setIndexHandler(handler int)
  189. setIndexRoute(route int)
  190. setMatched(matched bool)
  191. setSkipNonUseRoutes(skip bool)
  192. setRoute(route *Route)
  193. getPathOriginal() string
  194. // FullURL returns the full request URL (protocol + host + original URL).
  195. FullURL() string
  196. // UserAgent returns the User-Agent request header.
  197. UserAgent() string
  198. // Referer returns the Referer request header.
  199. Referer() string
  200. // AcceptLanguage returns the Accept-Language request header.
  201. AcceptLanguage() string
  202. // AcceptEncoding returns the Accept-Encoding request header.
  203. AcceptEncoding() string
  204. // HasHeader reports whether the request includes a header with the given key.
  205. HasHeader(key string) bool
  206. // MediaType returns the MIME type from the Content-Type header without parameters.
  207. MediaType() string
  208. // Charset returns the charset parameter from the Content-Type header.
  209. Charset() string
  210. // IsJSON reports whether the Content-Type header is JSON.
  211. IsJSON() bool
  212. // IsForm reports whether the Content-Type header is form-encoded.
  213. IsForm() bool
  214. // IsMultipart reports whether the Content-Type header is multipart form data.
  215. IsMultipart() bool
  216. // AcceptsJSON reports whether the Accept header allows JSON.
  217. AcceptsJSON() bool
  218. // AcceptsHTML reports whether the Accept header allows HTML.
  219. AcceptsHTML() bool
  220. // AcceptsXML reports whether the Accept header allows XML.
  221. AcceptsXML() bool
  222. // AcceptsEventStream reports whether the Accept header allows text/event-stream.
  223. AcceptsEventStream() bool
  224. // Accepts checks if the specified extensions or content types are acceptable.
  225. Accepts(offers ...string) string
  226. // AcceptsCharsets checks if the specified charset is acceptable.
  227. AcceptsCharsets(offers ...string) string
  228. // AcceptsEncodings checks if the specified encoding is acceptable.
  229. AcceptsEncodings(offers ...string) string
  230. // AcceptsLanguages checks if the specified language is acceptable using
  231. // RFC 4647 Basic Filtering.
  232. AcceptsLanguages(offers ...string) string
  233. // AcceptsLanguagesExtended checks if the specified language is acceptable using
  234. // RFC 4647 Extended Filtering.
  235. AcceptsLanguagesExtended(offers ...string) string
  236. // BodyRaw contains the raw body submitted in a POST request.
  237. // Returned value is only valid within the handler. Do not store any references.
  238. // Make copies or use the Immutable setting instead.
  239. BodyRaw() []byte
  240. //nolint:nonamedreturns // gocritic unnamedResult prefers naming decoded body, decode count, and error
  241. tryDecodeBodyInOrder(originalBody *[]byte, encodings []string) (body []byte, decodesRealized uint8, err error)
  242. // Body contains the raw body submitted in a POST request.
  243. // This method will decompress the body if the 'Content-Encoding' header is provided.
  244. // It returns the original (or decompressed) body data which is valid only within the handler.
  245. // Don't store direct references to the returned data.
  246. // If you need to keep the body's data later, make a copy or use the Immutable option.
  247. Body() []byte
  248. // Cookies are used for getting a cookie value by key.
  249. // Defaults to the empty string "" if the cookie doesn't exist.
  250. // If a default value is given, it will return that value if the cookie doesn't exist.
  251. // The returned value is only valid within the handler. Do not store any references.
  252. // Make copies or use the Immutable setting to use the value outside the Handler.
  253. Cookies(key string, defaultValue ...string) string
  254. // FormFile returns the first file by key from a MultipartForm.
  255. FormFile(key string) (*multipart.FileHeader, error)
  256. // FormValue returns the first value by key from a MultipartForm.
  257. // Search is performed in QueryArgs, PostArgs, MultipartForm and FormFile in this particular order.
  258. // Defaults to the empty string "" if the form value doesn't exist.
  259. // If a default value is given, it will return that value if the form value does not exist.
  260. // Returned value is only valid within the handler. Do not store any references.
  261. // Make copies or use the Immutable setting instead.
  262. FormValue(key string, defaultValue ...string) string
  263. // Fresh returns true when the response is still “fresh” in the client's cache,
  264. // otherwise false is returned to indicate that the client cache is now stale
  265. // and the full response should be sent.
  266. // When a client sends the Cache-Control: no-cache request header to indicate an end-to-end
  267. // reload request, this module will return false to make handling these requests transparent.
  268. // https://github.com/jshttp/fresh/blob/master/index.js#L33
  269. Fresh() bool
  270. // Host contains the host derived from the X-Forwarded-Host or Host HTTP header.
  271. // Returned value is only valid within the handler. Do not store any references.
  272. // In a network context, `Host` refers to the combination of a hostname and potentially a port number used for connecting,
  273. // while `Hostname` refers specifically to the name assigned to a device on a network, excluding any port information.
  274. // Example: URL: https://example.com:8080 -> Host: example.com:8080
  275. // Make copies or use the Immutable setting instead.
  276. // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy.
  277. Host() string
  278. // Hostname contains the hostname derived from the X-Forwarded-Host or Host HTTP header using the c.Host() method.
  279. // Returned value is only valid within the handler. Do not store any references.
  280. // Example: URL: https://example.com:8080 -> Hostname: example.com
  281. // Make copies or use the Immutable setting instead.
  282. // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy.
  283. Hostname() string
  284. // Port returns the remote port of the request.
  285. Port() string
  286. // IP returns the remote IP address of the request.
  287. // If ProxyHeader and IP Validation is configured, it will parse that header and return the first valid IP address.
  288. // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy.
  289. IP() string
  290. // extractIPsFromHeader will return a slice of IPs it found given a header name in the order they appear.
  291. // When IP validation is enabled, any invalid IPs will be omitted.
  292. extractIPsFromHeader(header string) []string
  293. // extractIPFromHeader will attempt to pull the real client IP from the given header when IP validation is enabled.
  294. // currently, it will return the first valid IP address in header.
  295. // when IP validation is disabled, it will simply return the value of the header without any inspection.
  296. // Implementation is almost the same as in extractIPsFromHeader, but without allocation of []string.
  297. extractIPFromHeader(header string) string
  298. // IPs returns a string slice of IP addresses specified in the X-Forwarded-For request header.
  299. // When IP validation is enabled, only valid IPs are returned.
  300. IPs() []string
  301. // Is returns the matching content type,
  302. // if the incoming request's Content-Type HTTP header field matches the MIME type specified by the type parameter
  303. Is(extension string) bool
  304. // Locals makes it possible to pass any values under keys scoped to the request
  305. // and therefore available to all following routes that match the request.
  306. //
  307. // All the values are removed from ctx after returning from the top
  308. // RequestHandler. Additionally, Close method is called on each value
  309. // implementing io.Closer before removing the value from ctx.
  310. Locals(key any, value ...any) any
  311. // Method returns the HTTP request method for the context, optionally overridden by the provided argument.
  312. // If no override is given or if the provided override is not a valid HTTP method, it returns the current method from the context.
  313. // Otherwise, it updates the context's method and returns the overridden method as a string.
  314. Method(override ...string) string
  315. // MultipartForm parse form entries from binary.
  316. // This returns a map[string][]string, so given a key, the value will be a string slice.
  317. MultipartForm() (*multipart.Form, error)
  318. // Params is used to get the route parameters.
  319. // Defaults to empty string "" if the param doesn't exist.
  320. // If a default value is given, it will return that value if the param doesn't exist.
  321. // Returned value is only valid within the handler. Do not store any references.
  322. // Make copies or use the Immutable setting to use the value outside the Handler.
  323. Params(key string, defaultValue ...string) string
  324. // Scheme contains the request protocol string: http or https for TLS requests.
  325. // Please use Config.TrustProxy to prevent header spoofing if your app is behind a proxy.
  326. Scheme() string
  327. // Protocol returns the HTTP protocol of request: HTTP/1.1 and HTTP/2.
  328. Protocol() string
  329. // Query returns the query string parameter in the url.
  330. // Defaults to empty string "" if the query doesn't exist.
  331. // If a default value is given, it will return that value if the query doesn't exist.
  332. // Returned value is only valid within the handler. Do not store any references.
  333. // Make copies or use the Immutable setting to use the value outside the Handler.
  334. Query(key string, defaultValue ...string) string
  335. // Queries returns a map of query parameters and their values.
  336. //
  337. // GET /?name=alex&wanna_cake=2&id=
  338. // Queries()["name"] == "alex"
  339. // Queries()["wanna_cake"] == "2"
  340. // Queries()["id"] == ""
  341. //
  342. // GET /?field1=value1&field1=value2&field2=value3
  343. // Queries()["field1"] == "value2"
  344. // Queries()["field2"] == "value3"
  345. //
  346. // GET /?list_a=1&list_a=2&list_a=3&list_b[]=1&list_b[]=2&list_b[]=3&list_c=1,2,3
  347. // Queries()["list_a"] == "3"
  348. // Queries()["list_b[]"] == "3"
  349. // Queries()["list_c"] == "1,2,3"
  350. //
  351. // GET /api/search?filters.author.name=John&filters.category.name=Technology&filters[customer][name]=Alice&filters[status]=pending
  352. // Queries()["filters.author.name"] == "John"
  353. // Queries()["filters.category.name"] == "Technology"
  354. // Queries()["filters[customer][name]"] == "Alice"
  355. // Queries()["filters[status]"] == "pending"
  356. Queries() map[string]string
  357. // Range returns a struct containing the type and a slice of ranges.
  358. Range(size int64) (Range, error)
  359. // Subdomains returns a slice of subdomains from the host, excluding the last `offset` components.
  360. // If the offset is negative or exceeds the number of subdomains, an empty slice is returned.
  361. // If the offset is zero every label (no trimming) is returned.
  362. Subdomains(offset ...int) []string
  363. // Stale returns the inverse of Fresh, indicating if the client's cached response is considered stale.
  364. Stale() bool
  365. // IsProxyTrusted checks trustworthiness of remote ip.
  366. // If Config.TrustProxy false, it returns false.
  367. // IsProxyTrusted can check remote ip by proxy ranges and ip map.
  368. IsProxyTrusted() bool
  369. // IsFromLocal will return true if request came from local.
  370. IsFromLocal() bool
  371. getBody() []byte
  372. // Append the specified value to the HTTP response header field.
  373. // If the header is not already set, it creates the header with the specified value.
  374. Append(field string, values ...string)
  375. // Attachment sets the HTTP response Content-Disposition header field to attachment.
  376. Attachment(filename ...string)
  377. // ClearCookie expires a specific cookie by key on the client side.
  378. // If no key is provided it expires all cookies that came with the request.
  379. ClearCookie(key ...string)
  380. // Cookie sets a cookie by passing a cookie struct.
  381. Cookie(cookie *Cookie)
  382. // Download transfers the file from path as an attachment.
  383. // Typically, browsers will prompt the user for download.
  384. // By default, the Content-Disposition header filename= parameter is the filepath (this typically appears in the browser dialog).
  385. // Override this default with the filename parameter.
  386. Download(file string, filename ...string) error
  387. // Format performs content-negotiation on the Accept HTTP header.
  388. // It uses Accepts to select a proper format and calls the matching
  389. // user-provided handler function.
  390. // If no accepted format is found, and a format with MediaType "default" is given,
  391. // that default handler is called. If no format is found and no default is given,
  392. // StatusNotAcceptable is sent.
  393. Format(handlers ...ResFmt) error
  394. // AutoFormat performs content-negotiation on the Accept HTTP header.
  395. // It uses Accepts to select a proper format.
  396. // The supported content types are text/html, text/plain, application/json, application/xml, application/vnd.msgpack, and application/cbor.
  397. // For more flexible content negotiation, use Format.
  398. // If the header is not specified or there is no proper format, text/plain is used.
  399. AutoFormat(body any) error
  400. // JSON converts any interface or string to JSON.
  401. // Array and slice values encode as JSON arrays,
  402. // except that []byte encodes as a base64-encoded string,
  403. // and a nil slice encodes as the null JSON value.
  404. // If the ctype parameter is given, this method will set the
  405. // Content-Type header equal to ctype. If ctype is not given,
  406. // The Content-Type header will be set to application/json; charset=utf-8.
  407. JSON(data any, ctype ...string) error
  408. // MsgPack converts any interface or string to MessagePack encoded bytes.
  409. // If the ctype parameter is given, this method will set the
  410. // Content-Type header equal to ctype. If ctype is not given,
  411. // The Content-Type header will be set to application/vnd.msgpack.
  412. MsgPack(data any, ctype ...string) error
  413. // CBOR converts any interface or string to CBOR encoded bytes.
  414. // If the ctype parameter is given, this method will set the
  415. // Content-Type header equal to ctype. If ctype is not given,
  416. // The Content-Type header will be set to application/cbor.
  417. CBOR(data any, ctype ...string) error
  418. // JSONP sends a JSON response with JSONP support.
  419. // This method is identical to JSON, except that it opts-in to JSONP callback support.
  420. // By default, the callback name is simply callback.
  421. JSONP(data any, callback ...string) error
  422. // XML converts any interface or string to XML.
  423. // This method also sets the content header to application/xml; charset=utf-8.
  424. XML(data any) error
  425. // Links joins the links followed by the property to populate the response's Link HTTP header field.
  426. Links(link ...string)
  427. // Location sets the response Location HTTP header to the specified path parameter.
  428. Location(path string)
  429. // getLocationFromRoute get URL location from route using parameters
  430. getLocationFromRoute(route *Route, params Map) (string, error)
  431. // GetRouteURL generates URLs to named routes, with parameters. URLs are relative, for example: "/user/1831"
  432. GetRouteURL(routeName string, params Map) (string, error)
  433. // Render a template with data and sends a text/html response.
  434. // We support the following engines: https://github.com/gofiber/template
  435. Render(name string, bind any, layouts ...string) error
  436. // Send sets the HTTP response body without copying it.
  437. // From this point onward the body argument must not be changed.
  438. Send(body []byte) error
  439. // SendEarlyHints allows the server to hint to the browser what resources a page would need
  440. // so the browser can preload them while waiting for the server's full response. Only Link
  441. // headers already written to the response will be transmitted as Early Hints.
  442. //
  443. // This is a HTTP/2+ feature but all browsers will either understand it or safely ignore it.
  444. //
  445. // NOTE: Older HTTP/1.1 non-browser clients may face compatibility issues.
  446. //
  447. // See: https://developer.chrome.com/docs/web-platform/early-hints and
  448. // https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link#syntax
  449. SendEarlyHints(hints []string) error
  450. // SendFile transfers the file from the specified path.
  451. // By default, the file is not compressed. To enable compression, set SendFile.Compress to true.
  452. // The Content-Type response HTTP header field is set based on the file's extension.
  453. // If the file extension is missing or invalid, the Content-Type is detected from the file's format.
  454. SendFile(file string, config ...SendFile) error
  455. // SendStatus sets the HTTP status code and if the response body is empty,
  456. // it sets the correct status message in the body.
  457. SendStatus(status int) error
  458. // SendString sets the HTTP response body for string types.
  459. // This means no type assertion, recommended for faster performance
  460. SendString(body string) error
  461. // SendStream sets response body stream and optional body size.
  462. SendStream(stream io.Reader, size ...int) error
  463. // SendStreamWriter sets response body stream writer
  464. SendStreamWriter(streamWriter func(*bufio.Writer)) error
  465. // Set sets the response's HTTP header field to the specified key, value.
  466. Set(key, val string)
  467. setCanonical(key, val string)
  468. // Type sets the Content-Type HTTP header to the MIME type specified by the file extension.
  469. Type(extension string, charset ...string) Ctx
  470. // Vary adds the given header field to the Vary response header.
  471. // This will append the header, if not already listed; otherwise, leaves it listed in the current location.
  472. Vary(fields ...string)
  473. // Write appends p into response body.
  474. Write(p []byte) (int, error)
  475. // Writef appends f & a into response body writer.
  476. Writef(f string, a ...any) (int, error)
  477. // WriteString appends s to response body.
  478. WriteString(s string) (int, error)
  479. // Drop closes the underlying connection without sending any response headers or body.
  480. // This can be useful for silently terminating client connections, such as in DDoS mitigation
  481. // or when blocking access to sensitive endpoints.
  482. Drop() error
  483. // End immediately flushes the current response and closes the underlying connection.
  484. End() error
  485. }