Skip to content

Commit bb91f32

Browse files
committed
feat(req,res): sync more missed methods
1 parent 3a8f64a commit bb91f32

File tree

4 files changed

+97
-34
lines changed

4 files changed

+97
-34
lines changed

req.go

+39-10
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
package fiber
22

33
import (
4+
"crypto/tls"
45
"mime/multipart"
56
)
67

@@ -33,6 +34,14 @@ func (r *DefaultReq) Body() []byte {
3334
return r.ctx.Body()
3435
}
3536

37+
func (r *DefaultReq) BodyRaw() []byte {
38+
return r.ctx.BodyRaw()
39+
}
40+
41+
func (r *DefaultReq) ClientHelloInfo() *tls.ClientHelloInfo {
42+
return r.ctx.ClientHelloInfo()
43+
}
44+
3645
func (r *DefaultReq) Cookies(key string, defaultValue ...string) string {
3746
return r.ctx.Cookies(key, defaultValue...)
3847
}
@@ -65,6 +74,10 @@ func (r *DefaultReq) IP() string {
6574
return r.ctx.IP()
6675
}
6776

77+
func (r *DefaultReq) IPs() []string {
78+
return r.ctx.IPs()
79+
}
80+
6881
func (r *DefaultReq) Is(extension string) bool {
6982
return r.ctx.Is(extension)
7083
}
@@ -73,12 +86,16 @@ func (r *DefaultReq) IsFromLocal() bool {
7386
return r.ctx.IsFromLocal()
7487
}
7588

76-
func (r *DefaultReq) IPs() []string {
77-
return r.ctx.IPs()
89+
func (r *DefaultReq) IsProxyTrusted() bool {
90+
return r.ctx.IsProxyTrusted()
7891
}
7992

80-
func (r *DefaultReq) Method() string {
81-
return r.ctx.Method()
93+
func (r *DefaultReq) Method(override ...string) string {
94+
return r.ctx.Method(override...)
95+
}
96+
97+
func (r *DefaultReq) MultipartForm() (*multipart.Form, error) {
98+
return r.ctx.MultipartForm()
8299
}
83100

84101
func (r *DefaultReq) OriginalURL() string {
@@ -89,22 +106,26 @@ func (r *DefaultReq) Params(key string, defaultValue ...string) string {
89106
return r.ctx.Params(key, defaultValue...)
90107
}
91108

92-
func (r *DefaultReq) Path() string {
93-
return r.ctx.Path()
109+
func (r *DefaultReq) Path(override ...string) string {
110+
return r.ctx.Path(override...)
94111
}
95112

96-
func (r *DefaultReq) Protocol() string {
97-
return r.ctx.Protocol()
113+
func (r *DefaultReq) Port() string {
114+
return r.ctx.Port()
98115
}
99116

100-
func (r *DefaultReq) Query(key string, defaultValue ...string) string {
101-
return r.ctx.Query(key, defaultValue...)
117+
func (r *DefaultReq) Protocol() string {
118+
return r.ctx.Protocol()
102119
}
103120

104121
func (r *DefaultReq) Queries() map[string]string {
105122
return r.ctx.Queries()
106123
}
107124

125+
func (r *DefaultReq) Query(key string, defaultValue ...string) string {
126+
return r.ctx.Query(key, defaultValue...)
127+
}
128+
108129
func (r *DefaultReq) Range(size int) (Range, error) {
109130
return r.ctx.Range(size)
110131
}
@@ -113,6 +134,14 @@ func (r *DefaultReq) Route() *Route {
113134
return r.ctx.Route()
114135
}
115136

137+
func (r *DefaultReq) SaveFile(fileheader *multipart.FileHeader, path string) error {
138+
return r.ctx.SaveFile(fileheader, path)
139+
}
140+
141+
func (r *DefaultReq) SaveFileToStorage(fileheader *multipart.FileHeader, path string, storage Storage) error {
142+
return r.ctx.SaveFileToStorage(fileheader, path, storage)
143+
}
144+
116145
func (r *DefaultReq) Secure() bool {
117146
return r.ctx.Secure()
118147
}

req_interface_gen.go

+12-4
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

res.go

+33-15
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
package fiber
22

3+
import (
4+
"bufio"
5+
)
6+
37
//go:generate ifacemaker --file res.go --struct DefaultRes --iface Res --pkg fiber --output res_interface_gen.go --not-exported true --iface-comment "Res"
48
type DefaultRes struct {
59
ctx *DefaultCtx
610
}
711

8-
func (r *DefaultRes) Locals(key any, value ...any) any {
9-
return r.ctx.Locals(key, value...)
10-
}
11-
1212
func (r *DefaultRes) Append(field string, values ...string) {
1313
r.ctx.Append(field, values...)
1414
}
@@ -25,14 +25,14 @@ func (r *DefaultRes) CBOR(body any, ctype ...string) error {
2525
return r.ctx.CBOR(body, ctype...)
2626
}
2727

28-
func (r *DefaultRes) Cookie(cookie *Cookie) {
29-
r.ctx.Cookie(cookie)
30-
}
31-
3228
func (r *DefaultRes) ClearCookie(key ...string) {
3329
r.ctx.ClearCookie(key...)
3430
}
3531

32+
func (r *DefaultRes) Cookie(cookie *Cookie) {
33+
r.ctx.Cookie(cookie)
34+
}
35+
3636
func (r *DefaultRes) Download(file string, filename ...string) error {
3737
return r.ctx.Download(file, filename...)
3838
}
@@ -61,7 +61,7 @@ func (r *DefaultRes) Location(path string) {
6161
r.ctx.Location(path)
6262
}
6363

64-
func (r *DefaultRes) Render(name string, bind Map, layouts ...string) error {
64+
func (r *DefaultRes) Render(name string, bind any, layouts ...string) error {
6565
return r.ctx.Render(name, bind, layouts...)
6666
}
6767

@@ -77,24 +77,42 @@ func (r *DefaultRes) SendStatus(status int) error {
7777
return r.ctx.SendStatus(status)
7878
}
7979

80+
func (r *DefaultRes) SendString(body string) error {
81+
return r.ctx.SendString(body)
82+
}
83+
84+
func (r *DefaultRes) SendStreamWriter(streamWriter func(*bufio.Writer)) error {
85+
return r.ctx.SendStreamWriter(streamWriter)
86+
}
87+
8088
func (r *DefaultRes) Set(key, val string) {
8189
r.ctx.Set(key, val)
8290
}
8391

84-
func (r *DefaultRes) Status(status int) Res {
85-
r.ctx.Status(status)
86-
return r
92+
func (r *DefaultRes) Status(status int) Ctx {
93+
return r.ctx.Status(status)
8794
}
8895

89-
func (r *DefaultRes) Type(extension string, charset ...string) Res {
90-
r.ctx.Type(extension, charset...)
91-
return r
96+
func (r *DefaultRes) Type(extension string, charset ...string) Ctx {
97+
return r.ctx.Type(extension, charset...)
9298
}
9399

94100
func (r *DefaultRes) Vary(fields ...string) {
95101
r.ctx.Vary(fields...)
96102
}
97103

104+
func (r *DefaultRes) Write(p []byte) (int, error) {
105+
return r.ctx.Write(p)
106+
}
107+
108+
func (r *DefaultRes) Writef(f string, a ...any) (int, error) {
109+
return r.ctx.Writef(f, a...)
110+
}
111+
112+
func (r *DefaultRes) WriteString(s string) (int, error) {
113+
return r.ctx.WriteString(s)
114+
}
115+
98116
func (r *DefaultRes) XML(data any) error {
99117
return r.ctx.XML(data)
100118
}

res_interface_gen.go

+13-5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)