-
-
Notifications
You must be signed in to change notification settings - Fork 2k
Expand file tree
/
Copy pathres_interface_gen.go
More file actions
232 lines (228 loc) · 13 KB
/
Copy pathres_interface_gen.go
File metadata and controls
232 lines (228 loc) · 13 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
// Code generated by ifacemaker; DO NOT EDIT.
package fiber
import (
"bufio"
"io"
"github.com/valyala/fasthttp"
)
// Res is an interface for response-related Ctx methods.
type Res interface {
// App returns the *App reference to the instance of the Fiber application
App() *App
// Append the specified value to the HTTP response header field.
// If the header is not already set, it creates the header with the specified value.
// Empty values are skipped: a sender must not generate empty list elements
// (RFC 9110 Section 5.6.1.2).
// Members are compared byte-exactly, because some lists (Link, Cache-Control)
// are not all field names. For Vary field names, use Vary, which folds case.
Append(field string, values ...string)
// Add appends the value as a new field line, where Append folds values into one
// comma-separated line. The headers fasthttp keeps in a slot of their own are
// the exception: Content-Type, Server and the rest are replaced and Date and TE
// ignored, though Set-Cookie is slotted and does append. Use Cookie for that.
Add(key, val string)
// Attachment sets the HTTP response Content-Disposition header field to attachment.
Attachment(filename ...string)
// ClearCookie expires a specific cookie by key on the client side.
// If no key is provided it expires all cookies that came with the request.
ClearCookie(key ...string)
// RequestCtx returns *fasthttp.RequestCtx that carries a deadline
// a cancellation signal, and other values across API boundaries.
RequestCtx() *fasthttp.RequestCtx
// Cookie sets a cookie by passing a cookie struct.
//
// The argument is treated as read-only: the normalization this method applies
// (default Path, SessionOnly, and the Secure implied by SameSite=None or
// Partitioned) happens on a local copy, so a caller may reuse the same *Cookie
// template across requests.
Cookie(cookie *Cookie)
// GetCookie reads back a cookie this response is set to send, false when the
// name is unset or its value does not parse. Names are case-sensitive and a
// repeat resolves to the first. Writing the copy back through Cookie stamps
// Path=/ on a cookie that carried none, widening its scope — set Path first.
GetCookie(name string) (*Cookie, bool)
// GetCookies returns a copy of every cookie this response is set to send, in
// order, or nil when there are none. Repeated names are kept apart, and an
// unparsable one is skipped. For what the client sent, use Req.Cookies.
//
// Named for GetCookie beside it rather than Cookies, which would collide with
// Req.Cookies under a different signature and stop Ctx satisfying Res.
GetCookies() []*Cookie
// Download transfers the file from path as an attachment.
// Typically, browsers will prompt the user for download.
// By default, the Content-Disposition header filename= parameter is the filepath (this typically appears in the browser dialog).
// Override this default with the filename parameter.
Download(file string, filename ...string) error
// Response return the *fasthttp.Response object
// This allows you to use all fasthttp response methods
// https://godoc.org/github.com/valyala/fasthttp#Response
Response() *fasthttp.Response
// Format performs content-negotiation on the Accept HTTP header.
// It uses Accepts to select a proper format and calls the matching
// user-provided handler function.
// If no accepted format is found, and a format with MediaType "default" is given,
// that default handler is called. If no format is found and no default is given,
// StatusNotAcceptable is sent.
Format(handlers ...ResFmt) error
// AutoFormat performs content-negotiation on the Accept HTTP header.
// It uses Accepts to select a proper format.
// The supported content types are text/html, text/plain, application/json, application/xml, application/vnd.msgpack, and application/cbor.
// When text/html is selected, the body is treated as plain text and HTML-escaped before being wrapped in a `<p>` element.
// For more flexible content negotiation, use Format.
// If the header is not specified or there is no proper format, text/plain is used.
AutoFormat(body any) error
// ContentLength returns what the Content-Length response header declares: a
// length a handler or upstream set, -1 for an unknown-length stream, 0 when
// none is declared. fasthttp fills it in on serialization; see also Res.Body.
ContentLength() int
// ContentType returns the Content-Type response header, the read side of Type.
// With none set it reports what would be sent: fasthttp's default, or "" under
// Config.DisableDefaultContentType. Only valid within the handler.
ContentType() string
// Del removes every field line stored under key, whatever case it is spelled in,
// and is a no-op for a header that was never set. Del(HeaderSetCookie) withdraws
// the pending cookies, where ClearCookie expires one in the client's jar.
Del(key string)
// Get (a.k.a. GetRespHeader) returns the HTTP response header specified by field.
// Field names are case-insensitive
// Returned value is only valid within the handler. Do not store any references.
// Make copies or use the Immutable setting instead.
Get(key string, defaultValue ...string) string
// GetHeaders (a.k.a GetRespHeaders) returns the HTTP response headers.
// Returned value is only valid within the handler. Do not store any references.
// Make copies or use the Immutable setting instead.
GetHeaders() map[string][]string
// JSON converts any interface or string to JSON.
// Array and slice values encode as JSON arrays,
// except that []byte encodes as a base64-encoded string,
// and a nil slice encodes as the null JSON value.
// If the ctype parameter is given, this method will set the
// Content-Type header equal to ctype. If ctype is not given,
// The Content-Type header will be set to application/json; charset=utf-8.
JSON(data any, ctype ...string) error
// MsgPack converts any interface or string to MessagePack encoded bytes.
// If the ctype parameter is given, this method will set the
// Content-Type header equal to ctype. If ctype is not given,
// The Content-Type header will be set to application/vnd.msgpack.
MsgPack(data any, ctype ...string) error
// CBOR converts any interface or string to CBOR encoded bytes.
// If the ctype parameter is given, this method will set the
// Content-Type header equal to ctype. If ctype is not given,
// The Content-Type header will be set to application/cbor.
CBOR(data any, ctype ...string) error
// JSONP sends a JSON response with JSONP support.
// This method is identical to JSON, except that it opts-in to JSONP callback support.
// By default, the callback name is simply callback.
//
// The callback name is reduced to a JavaScript member expression: everything
// outside [A-Za-z0-9_$.[]] is dropped. Callers routinely take the name straight
// from the query string, which is what JSONP is for, and the name lands
// verbatim in a same-origin text/javascript body — so an unfiltered one would
// let a request supply arbitrary script for the app's own origin.
JSONP(data any, callback ...string) error
// XML converts any interface or string to XML.
// This method also sets the content header to application/xml; charset=utf-8.
XML(data any) error
// Links joins the links followed by the property to populate the response's Link HTTP header field.
Links(link ...string)
// Location sets the response Location HTTP header to the specified path parameter.
Location(path string)
// OriginalURL contains the original request URL.
// Returned value is only valid within the handler. Do not store any references.
// Make copies or use the Immutable setting to use the value outside the Handler.
OriginalURL() string
// Redirect returns the Redirect reference.
// Use Redirect().Status() to set custom redirection status code.
// If status is not specified, status defaults to 303 See Other.
// You can use Redirect().To(), Redirect().Route() and Redirect().Back() for redirection.
Redirect() *Redirect
// ViewBind Add vars to default view var map binding to template engine.
// Variables are read by the Render method and may be overwritten.
ViewBind(vars Map) error
// getLocationFromRoute gets the URL location from a route using parameters.
// Nil receivers and missing routes return ErrNotFound to match Route.URL semantics.
getLocationFromRoute(route *Route, params Map) (string, error)
// GetRouteURL generates URLs to named routes, with parameters. URLs are relative, for example: "/user/1831"
GetRouteURL(routeName string, params Map) (string, error)
// Render a template with data and sends a text/html response.
// We support the following engines: https://github.com/gofiber/template
Render(name string, bind any, layouts ...string) error
renderExtensions(bind any)
// Body returns the response body buffered so far, or nil for a streamed one,
// which draining would de-stream; Written tells those apart. The buffer is live,
// so writing to it writes to the response, and the next write voids it.
Body() []byte
// ResetBody discards the response body, keeping the status and headers.
// Use it before replacing a partially written body — an error page over a
// half-rendered view, a cached body over a fresh one.
ResetBody()
// Written reports whether anything has been written to the response body, so a
// handler that produced one can be told from a handler that did not. A stream
// counts without being drained; a status or header alone does not.
Written() bool
// Send sets the HTTP response body without copying it.
// From this point onward the body argument must not be changed.
Send(body []byte) error
// SendEarlyHints allows the server to hint to the browser what resources a page would need
// so the browser can preload them while waiting for the server's full response. Only Link
// headers already written to the response will be transmitted as Early Hints.
//
// This is a HTTP/2+ feature but all browsers will either understand it or safely ignore it.
//
// NOTE: Older HTTP/1.1 non-browser clients may face compatibility issues.
//
// See: https://developer.chrome.com/docs/web-platform/early-hints and
// https://developer.mozilla.org/en-US/docs/Web/HTTP/Reference/Headers/Link#syntax
SendEarlyHints(hints []string) error
// SendFile transfers the file from the specified path.
// By default, the file is not compressed. To enable compression, set SendFile.Compress to true.
// The Content-Type response HTTP header field is set based on the file's extension.
// If the file extension is missing or invalid, the Content-Type is detected from the file's format.
SendFile(file string, config ...SendFile) error
// NoContent replies 204 No Content. SendStatus already discards the body; this
// drops the Content-Type too, since RFC 9110 Section 6.4.1 gives a 204 no
// content to describe. SendStatus(204) keeps it, so the two differ.
NoContent() error
// SendStatus sets the HTTP status code and if the response body is empty,
// it sets the correct status message in the body.
SendStatus(status int) error
// SendString sets the HTTP response body for string types.
// This means no type assertion, recommended for faster performance
SendString(body string) error
// SendStream sets response body stream and optional body size.
SendStream(stream io.Reader, size ...int) error
// SendStreamWriter sets response body stream writer
SendStreamWriter(streamWriter func(*bufio.Writer)) error
// Set sets the response's HTTP header field to the specified key, value.
Set(key, val string)
setCanonical(key, val string)
// Status sets the HTTP status for the response.
// This method is chainable.
Status(status int) Ctx
// StatusCode returns the status code set on the response, the read side of
// Status, and reports 200 until something sets another. After Next it is the
// status the chain settled on.
StatusCode() int
// Type sets the Content-Type HTTP header to the MIME type specified by the file extension.
Type(extension string, charset ...string) Ctx
// Vary adds the given header field to the Vary response header.
// This will append the header, if not already listed; otherwise, leaves it listed in the current location.
// Per RFC 9110 Section 12.5.5 the wildcard "*" only has meaning as the sole member of the field:
// once "*" is added (or already present), the header is collapsed to a single "*".
Vary(fields ...string)
// Write appends p into response body.
Write(p []byte) (int, error)
// Writef appends f & a into response body writer.
Writef(f string, a ...any) (int, error)
// WriteString appends s to response body.
WriteString(s string) (int, error)
// Drop closes the underlying connection without sending any response headers or body.
// This can be useful for silently terminating client connections, such as in DDoS mitigation
// or when blocking access to sensitive endpoints.
Drop() error
// End immediately flushes the current response and closes the underlying connection.
//
// Note: End does not work when using streaming (e.g. fasthttp's HijackConn or SendStream),
// because in streaming mode the connection is managed asynchronously and ctx.Conn() may return nil.
End() error
}