res_interface_gen.go 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163
  1. // Code generated by ifacemaker; DO NOT EDIT.
  2. package fiber
  3. import (
  4. "bufio"
  5. "io"
  6. "github.com/valyala/fasthttp"
  7. )
  8. // Res is an interface for response-related Ctx methods.
  9. type Res interface {
  10. // App returns the *App reference to the instance of the Fiber application
  11. App() *App
  12. // Append the specified value to the HTTP response header field.
  13. // If the header is not already set, it creates the header with the specified value.
  14. Append(field string, values ...string)
  15. // Attachment sets the HTTP response Content-Disposition header field to attachment.
  16. Attachment(filename ...string)
  17. // ClearCookie expires a specific cookie by key on the client side.
  18. // If no key is provided it expires all cookies that came with the request.
  19. ClearCookie(key ...string)
  20. // RequestCtx returns *fasthttp.RequestCtx that carries a deadline
  21. // a cancellation signal, and other values across API boundaries.
  22. RequestCtx() *fasthttp.RequestCtx
  23. // Cookie sets a cookie by passing a cookie struct.
  24. Cookie(cookie *Cookie)
  25. // Download transfers the file from path as an attachment.
  26. // Typically, browsers will prompt the user for download.
  27. // By default, the Content-Disposition header filename= parameter is the filepath (this typically appears in the browser dialog).
  28. // Override this default with the filename parameter.
  29. Download(file string, filename ...string) error
  30. // Response return the *fasthttp.Response object
  31. // This allows you to use all fasthttp response methods
  32. // https://godoc.org/github.com/valyala/fasthttp#Response
  33. Response() *fasthttp.Response
  34. // Format performs content-negotiation on the Accept HTTP header.
  35. // It uses Accepts to select a proper format and calls the matching
  36. // user-provided handler function.
  37. // If no accepted format is found, and a format with MediaType "default" is given,
  38. // that default handler is called. If no format is found and no default is given,
  39. // StatusNotAcceptable is sent.
  40. Format(handlers ...ResFmt) error
  41. // AutoFormat performs content-negotiation on the Accept HTTP header.
  42. // It uses Accepts to select a proper format.
  43. // The supported content types are text/html, text/plain, application/json, application/xml, application/vnd.msgpack, and application/cbor.
  44. // For more flexible content negotiation, use Format.
  45. // If the header is not specified or there is no proper format, text/plain is used.
  46. AutoFormat(body any) error
  47. // Get (a.k.a. GetRespHeader) returns the HTTP response header specified by field.
  48. // Field names are case-insensitive
  49. // Returned value is only valid within the handler. Do not store any references.
  50. // Make copies or use the Immutable setting instead.
  51. Get(key string, defaultValue ...string) string
  52. // GetHeaders (a.k.a GetRespHeaders) returns the HTTP response headers.
  53. // Returned value is only valid within the handler. Do not store any references.
  54. // Make copies or use the Immutable setting instead.
  55. GetHeaders() map[string][]string
  56. // JSON converts any interface or string to JSON.
  57. // Array and slice values encode as JSON arrays,
  58. // except that []byte encodes as a base64-encoded string,
  59. // and a nil slice encodes as the null JSON value.
  60. // If the ctype parameter is given, this method will set the
  61. // Content-Type header equal to ctype. If ctype is not given,
  62. // The Content-Type header will be set to application/json; charset=utf-8.
  63. JSON(data any, ctype ...string) error
  64. // MsgPack converts any interface or string to MessagePack encoded bytes.
  65. // If the ctype parameter is given, this method will set the
  66. // Content-Type header equal to ctype. If ctype is not given,
  67. // The Content-Type header will be set to application/vnd.msgpack.
  68. MsgPack(data any, ctype ...string) error
  69. // CBOR converts any interface or string to CBOR encoded bytes.
  70. // If the ctype parameter is given, this method will set the
  71. // Content-Type header equal to ctype. If ctype is not given,
  72. // The Content-Type header will be set to application/cbor.
  73. CBOR(data any, ctype ...string) error
  74. // JSONP sends a JSON response with JSONP support.
  75. // This method is identical to JSON, except that it opts-in to JSONP callback support.
  76. // By default, the callback name is simply callback.
  77. JSONP(data any, callback ...string) error
  78. // XML converts any interface or string to XML.
  79. // This method also sets the content header to application/xml; charset=utf-8.
  80. XML(data any) error
  81. // Links joins the links followed by the property to populate the response's Link HTTP header field.
  82. Links(link ...string)
  83. // Location sets the response Location HTTP header to the specified path parameter.
  84. Location(path string)
  85. // OriginalURL contains the original request URL.
  86. // Returned value is only valid within the handler. Do not store any references.
  87. // Make copies or use the Immutable setting to use the value outside the Handler.
  88. OriginalURL() string
  89. // Redirect returns the Redirect reference.
  90. // Use Redirect().Status() to set custom redirection status code.
  91. // If status is not specified, status defaults to 303 See Other.
  92. // You can use Redirect().To(), Redirect().Route() and Redirect().Back() for redirection.
  93. Redirect() *Redirect
  94. // ViewBind Add vars to default view var map binding to template engine.
  95. // Variables are read by the Render method and may be overwritten.
  96. ViewBind(vars Map) error
  97. // getLocationFromRoute get URL location from route using parameters
  98. getLocationFromRoute(route *Route, params Map) (string, error)
  99. // GetRouteURL generates URLs to named routes, with parameters. URLs are relative, for example: "/user/1831"
  100. GetRouteURL(routeName string, params Map) (string, error)
  101. // Render a template with data and sends a text/html response.
  102. // We support the following engines: https://github.com/gofiber/template
  103. Render(name string, bind any, layouts ...string) error
  104. renderExtensions(bind any)
  105. // Send sets the HTTP response body without copying it.
  106. // From this point onward the body argument must not be changed.
  107. Send(body []byte) error
  108. // SendEarlyHints allows the server to hint to the browser what resources a page would need
  109. // so the browser can preload them while waiting for the server's full response. Only Link
  110. // headers already written to the response will be transmitted as Early Hints.
  111. //
  112. // This is a HTTP/2+ feature but all browsers will either understand it or safely ignore it.
  113. //
  114. // NOTE: Older HTTP/1.1 non-browser clients may face compatibility issues.
  115. //
  116. // See: https://developer.chrome.com/docs/web-platform/early-hints and
  117. // https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link#syntax
  118. SendEarlyHints(hints []string) error
  119. // SendFile transfers the file from the specified path.
  120. // By default, the file is not compressed. To enable compression, set SendFile.Compress to true.
  121. // The Content-Type response HTTP header field is set based on the file's extension.
  122. // If the file extension is missing or invalid, the Content-Type is detected from the file's format.
  123. SendFile(file string, config ...SendFile) error
  124. // SendStatus sets the HTTP status code and if the response body is empty,
  125. // it sets the correct status message in the body.
  126. SendStatus(status int) error
  127. // SendString sets the HTTP response body for string types.
  128. // This means no type assertion, recommended for faster performance
  129. SendString(body string) error
  130. // SendStream sets response body stream and optional body size.
  131. SendStream(stream io.Reader, size ...int) error
  132. // SendStreamWriter sets response body stream writer
  133. SendStreamWriter(streamWriter func(*bufio.Writer)) error
  134. // Set sets the response's HTTP header field to the specified key, value.
  135. Set(key, val string)
  136. setCanonical(key, val string)
  137. // Status sets the HTTP status for the response.
  138. // This method is chainable.
  139. Status(status int) Ctx
  140. // Type sets the Content-Type HTTP header to the MIME type specified by the file extension.
  141. Type(extension string, charset ...string) Ctx
  142. // Vary adds the given header field to the Vary response header.
  143. // This will append the header, if not already listed; otherwise, leaves it listed in the current location.
  144. Vary(fields ...string)
  145. // Write appends p into response body.
  146. Write(p []byte) (int, error)
  147. // Writef appends f & a into response body writer.
  148. Writef(f string, a ...any) (int, error)
  149. // WriteString appends s to response body.
  150. WriteString(s string) (int, error)
  151. // Release is a method to reset Res fields when to use ReleaseCtx()
  152. release()
  153. // Drop closes the underlying connection without sending any response headers or body.
  154. // This can be useful for silently terminating client connections, such as in DDoS mitigation
  155. // or when blocking access to sensitive endpoints.
  156. Drop() error
  157. // End immediately flushes the current response and closes the underlying connection.
  158. End() error
  159. }