Skip to content

Commit

Permalink
feat(req,res): sync more missed methods
Browse files Browse the repository at this point in the history
  • Loading branch information
nickajacks1 committed Feb 24, 2025
1 parent 3a8f64a commit bb91f32
Show file tree
Hide file tree
Showing 4 changed files with 97 additions and 34 deletions.
49 changes: 39 additions & 10 deletions req.go
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
package fiber

import (
"crypto/tls"
"mime/multipart"
)

Expand Down Expand Up @@ -33,6 +34,14 @@ func (r *DefaultReq) Body() []byte {
return r.ctx.Body()

Check warning on line 34 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L33-L34

Added lines #L33 - L34 were not covered by tests
}

func (r *DefaultReq) BodyRaw() []byte {
return r.ctx.BodyRaw()

Check warning on line 38 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L37-L38

Added lines #L37 - L38 were not covered by tests
}

func (r *DefaultReq) ClientHelloInfo() *tls.ClientHelloInfo {
return r.ctx.ClientHelloInfo()

Check warning on line 42 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L41-L42

Added lines #L41 - L42 were not covered by tests
}

func (r *DefaultReq) Cookies(key string, defaultValue ...string) string {
return r.ctx.Cookies(key, defaultValue...)
}
Expand Down Expand Up @@ -65,6 +74,10 @@ func (r *DefaultReq) IP() string {
return r.ctx.IP()
}

func (r *DefaultReq) IPs() []string {
return r.ctx.IPs()

Check warning on line 78 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L77-L78

Added lines #L77 - L78 were not covered by tests
}

func (r *DefaultReq) Is(extension string) bool {
return r.ctx.Is(extension)

Check warning on line 82 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L81-L82

Added lines #L81 - L82 were not covered by tests
}
Expand All @@ -73,12 +86,16 @@ func (r *DefaultReq) IsFromLocal() bool {
return r.ctx.IsFromLocal()
}

func (r *DefaultReq) IPs() []string {
return r.ctx.IPs()
func (r *DefaultReq) IsProxyTrusted() bool {
return r.ctx.IsProxyTrusted()

Check warning on line 90 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L89-L90

Added lines #L89 - L90 were not covered by tests
}

func (r *DefaultReq) Method() string {
return r.ctx.Method()
func (r *DefaultReq) Method(override ...string) string {
return r.ctx.Method(override...)

Check warning on line 94 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L93-L94

Added lines #L93 - L94 were not covered by tests
}

func (r *DefaultReq) MultipartForm() (*multipart.Form, error) {
return r.ctx.MultipartForm()

Check warning on line 98 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L97-L98

Added lines #L97 - L98 were not covered by tests
}

func (r *DefaultReq) OriginalURL() string {
Expand All @@ -89,22 +106,26 @@ func (r *DefaultReq) Params(key string, defaultValue ...string) string {
return r.ctx.Params(key, defaultValue...)

Check warning on line 106 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L105-L106

Added lines #L105 - L106 were not covered by tests
}

func (r *DefaultReq) Path() string {
return r.ctx.Path()
func (r *DefaultReq) Path(override ...string) string {
return r.ctx.Path(override...)

Check warning on line 110 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L109-L110

Added lines #L109 - L110 were not covered by tests
}

func (r *DefaultReq) Protocol() string {
return r.ctx.Protocol()
func (r *DefaultReq) Port() string {
return r.ctx.Port()

Check warning on line 114 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L113-L114

Added lines #L113 - L114 were not covered by tests
}

func (r *DefaultReq) Query(key string, defaultValue ...string) string {
return r.ctx.Query(key, defaultValue...)
func (r *DefaultReq) Protocol() string {
return r.ctx.Protocol()

Check warning on line 118 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L117-L118

Added lines #L117 - L118 were not covered by tests
}

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

func (r *DefaultReq) Query(key string, defaultValue ...string) string {
return r.ctx.Query(key, defaultValue...)

Check warning on line 126 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L125-L126

Added lines #L125 - L126 were not covered by tests
}

func (r *DefaultReq) Range(size int) (Range, error) {
return r.ctx.Range(size)

Check warning on line 130 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L129-L130

Added lines #L129 - L130 were not covered by tests
}
Expand All @@ -113,6 +134,14 @@ func (r *DefaultReq) Route() *Route {
return r.ctx.Route()

Check warning on line 134 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L133-L134

Added lines #L133 - L134 were not covered by tests
}

func (r *DefaultReq) SaveFile(fileheader *multipart.FileHeader, path string) error {
return r.ctx.SaveFile(fileheader, path)

Check warning on line 138 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L137-L138

Added lines #L137 - L138 were not covered by tests
}

func (r *DefaultReq) SaveFileToStorage(fileheader *multipart.FileHeader, path string, storage Storage) error {
return r.ctx.SaveFileToStorage(fileheader, path, storage)

Check warning on line 142 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L141-L142

Added lines #L141 - L142 were not covered by tests
}

func (r *DefaultReq) Secure() bool {
return r.ctx.Secure()

Check warning on line 146 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L145-L146

Added lines #L145 - L146 were not covered by tests
}
Expand Down
16 changes: 12 additions & 4 deletions req_interface_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

48 changes: 33 additions & 15 deletions res.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package fiber

import (
"bufio"
)

//go:generate ifacemaker --file res.go --struct DefaultRes --iface Res --pkg fiber --output res_interface_gen.go --not-exported true --iface-comment "Res"
type DefaultRes struct {
ctx *DefaultCtx
}

func (r *DefaultRes) Locals(key any, value ...any) any {
return r.ctx.Locals(key, value...)
}

func (r *DefaultRes) Append(field string, values ...string) {
r.ctx.Append(field, values...)

Check warning on line 13 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L12-L13

Added lines #L12 - L13 were not covered by tests
}
Expand All @@ -25,14 +25,14 @@ func (r *DefaultRes) CBOR(body any, ctype ...string) error {
return r.ctx.CBOR(body, ctype...)

Check warning on line 25 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L24-L25

Added lines #L24 - L25 were not covered by tests
}

func (r *DefaultRes) Cookie(cookie *Cookie) {
r.ctx.Cookie(cookie)
}

func (r *DefaultRes) ClearCookie(key ...string) {
r.ctx.ClearCookie(key...)
}

func (r *DefaultRes) Cookie(cookie *Cookie) {
r.ctx.Cookie(cookie)
}

func (r *DefaultRes) Download(file string, filename ...string) error {
return r.ctx.Download(file, filename...)
}
Expand Down Expand Up @@ -61,7 +61,7 @@ func (r *DefaultRes) Location(path string) {
r.ctx.Location(path)

Check warning on line 61 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L60-L61

Added lines #L60 - L61 were not covered by tests
}

func (r *DefaultRes) Render(name string, bind Map, layouts ...string) error {
func (r *DefaultRes) Render(name string, bind any, layouts ...string) error {
return r.ctx.Render(name, bind, layouts...)
}

Expand All @@ -77,24 +77,42 @@ func (r *DefaultRes) SendStatus(status int) error {
return r.ctx.SendStatus(status)

Check warning on line 77 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L76-L77

Added lines #L76 - L77 were not covered by tests
}

func (r *DefaultRes) SendString(body string) error {
return r.ctx.SendString(body)

Check warning on line 81 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L80-L81

Added lines #L80 - L81 were not covered by tests
}

func (r *DefaultRes) SendStreamWriter(streamWriter func(*bufio.Writer)) error {
return r.ctx.SendStreamWriter(streamWriter)

Check warning on line 85 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L84-L85

Added lines #L84 - L85 were not covered by tests
}

func (r *DefaultRes) Set(key, val string) {
r.ctx.Set(key, val)

Check warning on line 89 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L88-L89

Added lines #L88 - L89 were not covered by tests
}

func (r *DefaultRes) Status(status int) Res {
r.ctx.Status(status)
return r
func (r *DefaultRes) Status(status int) Ctx {
return r.ctx.Status(status)
}

func (r *DefaultRes) Type(extension string, charset ...string) Res {
r.ctx.Type(extension, charset...)
return r
func (r *DefaultRes) Type(extension string, charset ...string) Ctx {
return r.ctx.Type(extension, charset...)

Check warning on line 97 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L96-L97

Added lines #L96 - L97 were not covered by tests
}

func (r *DefaultRes) Vary(fields ...string) {
r.ctx.Vary(fields...)

Check warning on line 101 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L100-L101

Added lines #L100 - L101 were not covered by tests
}

func (r *DefaultRes) Write(p []byte) (int, error) {
return r.ctx.Write(p)

Check warning on line 105 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L104-L105

Added lines #L104 - L105 were not covered by tests
}

func (r *DefaultRes) Writef(f string, a ...any) (int, error) {
return r.ctx.Writef(f, a...)

Check warning on line 109 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L108-L109

Added lines #L108 - L109 were not covered by tests
}

func (r *DefaultRes) WriteString(s string) (int, error) {
return r.ctx.WriteString(s)

Check warning on line 113 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L112-L113

Added lines #L112 - L113 were not covered by tests
}

func (r *DefaultRes) XML(data any) error {
return r.ctx.XML(data)

Check warning on line 117 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L116-L117

Added lines #L116 - L117 were not covered by tests
}
18 changes: 13 additions & 5 deletions res_interface_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bb91f32

Please sign in to comment.