Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Feature: Add Req and Res API #2894

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions ctx.go
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,8 @@
fasthttp *fasthttp.RequestCtx // Reference to *fasthttp.RequestCtx
bind *Bind // Default bind reference
redirect *Redirect // Default redirect reference
req *DefaultReq // Default request api reference
res *DefaultRes // Default response api reference
values [maxParams]string // Route parameter values
viewBindMap sync.Map // Default view map to bind template engine
method string // HTTP method
Expand Down Expand Up @@ -1463,6 +1465,18 @@
}
}

// Res returns a convenience type whose API is limited to operations
// on the incoming request.
func (c *DefaultCtx) Req() Req {
return c.req

Check warning on line 1471 in ctx.go

View check run for this annotation

Codecov / codecov/patch

ctx.go#L1470-L1471

Added lines #L1470 - L1471 were not covered by tests
}
Comment on lines +1468 to +1472
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Add test coverage for the Req() method

The method needs test coverage to ensure it correctly returns the req field. Here's a suggested test structure:

  • Add a test case in ctx_test.go that:
    • Creates a new DefaultCtx instance
    • Sets a known request value
    • Calls Req() and verifies it returns the expected request
    • Verifies that modifications to the returned request reflect in the context
🔗 Analysis chain

Add test coverage for the Req() method

While the implementation is correct and the documentation is clear, test coverage is missing for this method. Please add unit tests to ensure the method correctly returns the req field.

Would you like me to help generate unit tests for this method?

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify test coverage for Req() method
# Test: Search for test cases covering Req(). Expect: Test cases for the method.
rg --type go 'func Test.*Req\(' app/

Length of output: 83


Script:

#!/bin/bash
# First, let's find the correct location of test files
fd -e go test

# Then search for existing test cases for Req() method
rg --type go 'func Test.*Req\('

# Also search for any usage of Req() in test files to catch cases where it might be tested as part of other test cases
rg --type go -g '*_test.go' '\.Req\(\)'

Length of output: 2112


Script:

#!/bin/bash
# Let's check ctx_test.go specifically since it should contain tests for DefaultCtx
cat ctx_test.go | grep -A 20 -B 20 'Req()'

# Also let's verify if there are any indirect tests of Req() method
rg -g '*_test.go' -B 5 -A 5 'req :?= .*Req\(\)'

# Let's also check the implementation to understand the testing needs better
ast-grep --pattern 'func (c *DefaultCtx) Req() Req'

Length of output: 233

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 1470-1471: ctx.go#L1470-L1471
Added lines #L1470 - L1471 were not covered by tests


// Res returns a convenience type whose API is limited to operations
// on the outgoing response.
func (c *DefaultCtx) Res() Res {
return c.res

Check warning on line 1477 in ctx.go

View check run for this annotation

Codecov / codecov/patch

ctx.go#L1476-L1477

Added lines #L1476 - L1477 were not covered by tests
}
Comment on lines +1474 to +1478
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codebase verification

Add test coverage for the Res() method

The review comment is correct. The codebase search reveals that while there are interface and implementation definitions for Res, there is no direct test coverage for the Res() method of DefaultCtx. A test should be added to verify that:

  1. The method returns the internal res field
  2. The returned value implements the Res interface
  3. Operations on the returned value affect the context's response
🔗 Analysis chain

Add test coverage for the Res() method

While the implementation is correct and the documentation is clear, test coverage is missing for this method. Please add unit tests to ensure the method correctly returns the res field.

Would you like me to help generate unit tests for this method?

🏁 Scripts executed

The following scripts were executed for the analysis:

Script:

#!/bin/bash
# Description: Verify test coverage for Res() method
# Test: Search for test cases covering Res(). Expect: Test cases for the method.
rg --type go 'func Test.*Res\(' app/

Length of output: 83


Script:

#!/bin/bash
# First, let's find the correct location of test files
fd -e go test

# Then search for any existing test coverage of Res() method
rg --type go 'func Test.*Res\('

# Also search for any usage of Res() in test files to catch potential indirect testing
rg --type go '\.Res\(' -g '*test.go'

Length of output: 2109


Script:

#!/bin/bash
# Let's check ctx_test.go specifically since Res() is defined in ctx.go
cat ctx_test.go | grep -A 10 -B 10 "Res()"

# Also check for any indirect testing of the response functionality
rg --type go "c\.res\b" ctx_test.go

# Let's also look for any tests that might be using the Res type
rg --type go "type.*Res\b" -A 5

Length of output: 620

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 1476-1477: ctx.go#L1476-L1477
Added lines #L1476 - L1477 were not covered by tests


// Route returns the matched Route struct.
func (c *DefaultCtx) Route() *Route {
if c.route == nil {
Expand Down
2 changes: 2 additions & 0 deletions ctx_interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,8 @@ func NewDefaultCtx(app *App) *DefaultCtx {
return &DefaultCtx{
// Set app reference
app: app,
req: &DefaultReq{},
res: &DefaultRes{},
Comment on lines +38 to +39
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Fix initialization of req and res fields

The current initialization creates empty structs without setting the context reference. This will likely cause issues when methods try to access the context.

Apply this diff to properly initialize the fields:

-		req: &DefaultReq{},
-		res: &DefaultRes{},
+		req: &DefaultReq{ctx: c},
+		res: &DefaultRes{ctx: c},
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
req: &DefaultReq{},
res: &DefaultRes{},
req: &DefaultReq{ctx: c},
res: &DefaultRes{ctx: c},

}
}

Expand Down
6 changes: 6 additions & 0 deletions ctx_interface_gen.go

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

110 changes: 110 additions & 0 deletions req.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
package fiber

//go:generate ifacemaker --file req.go --struct DefaultReq --iface Req --pkg fiber --output req_interface_gen.go --not-exported true --iface-comment "Req"
type DefaultReq struct {
ctx *DefaultCtx
}
Comment on lines +4 to +6
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

Consider adding validation for ctx field.

The DefaultReq struct should validate that the ctx field is not nil during initialization to prevent potential panics.

 type DefaultReq struct {
 	ctx *DefaultCtx
 }
+
+func NewDefaultReq(ctx *DefaultCtx) (*DefaultReq, error) {
+	if ctx == nil {
+		return nil, errors.New("context cannot be nil")
+	}
+	return &DefaultReq{ctx: ctx}, nil
+}

Committable suggestion skipped: line range outside the PR's diff.


func (r *DefaultReq) Accepts(offers ...string) string {
return r.ctx.Accepts(offers...)

Check warning on line 9 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L8-L9

Added lines #L8 - L9 were not covered by tests
}

func (r *DefaultReq) AcceptsCharsets(offers ...string) string {
return r.ctx.AcceptsCharsets(offers...)

Check warning on line 13 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L12-L13

Added lines #L12 - L13 were not covered by tests
}

func (r *DefaultReq) AcceptsEncodings(offers ...string) string {
return r.ctx.AcceptsEncodings(offers...)

Check warning on line 17 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L16-L17

Added lines #L16 - L17 were not covered by tests
}

func (r *DefaultReq) AcceptsLanguages(offers ...string) string {
return r.ctx.AcceptsLanguages(offers...)

Check warning on line 21 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L20-L21

Added lines #L20 - L21 were not covered by tests
}

func (r *DefaultReq) BaseURL() string {
return r.ctx.BaseURL()

Check warning on line 25 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L24-L25

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

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

Check warning on line 29 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L28-L29

Added lines #L28 - L29 were not covered by tests
}

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

Check warning on line 33 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L32-L33

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

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

Check warning on line 37 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L36-L37

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

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

Check warning on line 41 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L40-L41

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

func (r *DefaultReq) Host() string {
return r.ctx.Host()

Check warning on line 45 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L44-L45

Added lines #L44 - L45 were not covered by tests
}

func (r *DefaultReq) Hostname() string {
return r.ctx.Hostname()

Check warning on line 49 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L48-L49

Added lines #L48 - L49 were not covered by tests
}

func (r *DefaultReq) IP() string {
return r.ctx.IP()

Check warning on line 53 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L52-L53

Added lines #L52 - L53 were not covered by tests
}

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

Check warning on line 57 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L56-L57

Added lines #L56 - L57 were not covered by tests
}

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

Check warning on line 61 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L60-L61

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

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

Check warning on line 65 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L64-L65

Added lines #L64 - L65 were not covered by tests
}

func (r *DefaultReq) OriginalURL() string {
return r.ctx.OriginalURL()

Check warning on line 69 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L68-L69

Added lines #L68 - L69 were not covered by tests
}

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

Check warning on line 73 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L72-L73

Added lines #L72 - L73 were not covered by tests
}

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

Check warning on line 77 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L76-L77

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

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

Check warning on line 81 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L80-L81

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

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

Check warning on line 85 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L84-L85

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

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

Check warning on line 89 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L88-L89

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

func (r *DefaultReq) Route() *Route {
return r.ctx.Route()

Check warning on line 93 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L92-L93

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

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

Check warning on line 97 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L96-L97

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

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

Check warning on line 101 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L100-L101

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

func (r *DefaultReq) Subdomains(offset ...int) []string {
return r.ctx.Subdomains(offset...)

Check warning on line 105 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L104-L105

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

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

Check warning on line 109 in req.go

View check run for this annotation

Codecov / codecov/patch

req.go#L108-L109

Added lines #L108 - L109 were not covered by tests
}
Comment on lines +1 to +110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add unit tests for the request API methods.

The static analysis indicates that the new request API methods lack test coverage. Comprehensive testing is essential for validating the delegation behavior.

Would you like me to help generate comprehensive unit tests for these methods?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 8-9: req.go#L8-L9
Added lines #L8 - L9 were not covered by tests


[warning] 12-13: req.go#L12-L13
Added lines #L12 - L13 were not covered by tests


[warning] 16-17: req.go#L16-L17
Added lines #L16 - L17 were not covered by tests


[warning] 20-21: req.go#L20-L21
Added lines #L20 - L21 were not covered by tests


[warning] 24-25: req.go#L24-L25
Added lines #L24 - L25 were not covered by tests


[warning] 28-29: req.go#L28-L29
Added lines #L28 - L29 were not covered by tests


[warning] 32-33: req.go#L32-L33
Added lines #L32 - L33 were not covered by tests


[warning] 36-37: req.go#L36-L37
Added lines #L36 - L37 were not covered by tests


[warning] 40-41: req.go#L40-L41
Added lines #L40 - L41 were not covered by tests


[warning] 44-45: req.go#L44-L45
Added lines #L44 - L45 were not covered by tests


[warning] 48-49: req.go#L48-L49
Added lines #L48 - L49 were not covered by tests


[warning] 52-53: req.go#L52-L53
Added lines #L52 - L53 were not covered by tests


[warning] 56-57: req.go#L56-L57
Added lines #L56 - L57 were not covered by tests


[warning] 60-61: req.go#L60-L61
Added lines #L60 - L61 were not covered by tests


[warning] 64-65: req.go#L64-L65
Added lines #L64 - L65 were not covered by tests


[warning] 68-69: req.go#L68-L69
Added lines #L68 - L69 were not covered by tests


[warning] 72-73: req.go#L72-L73
Added lines #L72 - L73 were not covered by tests


[warning] 76-77: req.go#L76-L77
Added lines #L76 - L77 were not covered by tests


[warning] 80-81: req.go#L80-L81
Added lines #L80 - L81 were not covered by tests


[warning] 84-85: req.go#L84-L85
Added lines #L84 - L85 were not covered by tests


[warning] 88-89: req.go#L88-L89
Added lines #L88 - L89 were not covered by tests


[warning] 92-93: req.go#L92-L93
Added lines #L92 - L93 were not covered by tests


[warning] 96-97: req.go#L96-L97
Added lines #L96 - L97 were not covered by tests


[warning] 100-101: req.go#L100-L101
Added lines #L100 - L101 were not covered by tests


[warning] 104-105: req.go#L104-L105
Added lines #L104 - L105 were not covered by tests


[warning] 108-109: req.go#L108-L109
Added lines #L108 - L109 were not covered by tests

Comment on lines +4 to +110
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add unit tests for the request API methods.

The static analysis indicates that the new request API methods lack test coverage. Comprehensive testing is essential for validating the delegation behavior.

Would you like me to help generate comprehensive unit tests for these methods?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 8-9: req.go#L8-L9
Added lines #L8 - L9 were not covered by tests


[warning] 12-13: req.go#L12-L13
Added lines #L12 - L13 were not covered by tests


[warning] 16-17: req.go#L16-L17
Added lines #L16 - L17 were not covered by tests


[warning] 20-21: req.go#L20-L21
Added lines #L20 - L21 were not covered by tests


[warning] 24-25: req.go#L24-L25
Added lines #L24 - L25 were not covered by tests


[warning] 28-29: req.go#L28-L29
Added lines #L28 - L29 were not covered by tests


[warning] 32-33: req.go#L32-L33
Added lines #L32 - L33 were not covered by tests


[warning] 36-37: req.go#L36-L37
Added lines #L36 - L37 were not covered by tests


[warning] 40-41: req.go#L40-L41
Added lines #L40 - L41 were not covered by tests


[warning] 44-45: req.go#L44-L45
Added lines #L44 - L45 were not covered by tests


[warning] 48-49: req.go#L48-L49
Added lines #L48 - L49 were not covered by tests


[warning] 52-53: req.go#L52-L53
Added lines #L52 - L53 were not covered by tests


[warning] 56-57: req.go#L56-L57
Added lines #L56 - L57 were not covered by tests


[warning] 60-61: req.go#L60-L61
Added lines #L60 - L61 were not covered by tests


[warning] 64-65: req.go#L64-L65
Added lines #L64 - L65 were not covered by tests


[warning] 68-69: req.go#L68-L69
Added lines #L68 - L69 were not covered by tests


[warning] 72-73: req.go#L72-L73
Added lines #L72 - L73 were not covered by tests


[warning] 76-77: req.go#L76-L77
Added lines #L76 - L77 were not covered by tests


[warning] 80-81: req.go#L80-L81
Added lines #L80 - L81 were not covered by tests


[warning] 84-85: req.go#L84-L85
Added lines #L84 - L85 were not covered by tests


[warning] 88-89: req.go#L88-L89
Added lines #L88 - L89 were not covered by tests


[warning] 92-93: req.go#L92-L93
Added lines #L92 - L93 were not covered by tests


[warning] 96-97: req.go#L96-L97
Added lines #L96 - L97 were not covered by tests


[warning] 100-101: req.go#L100-L101
Added lines #L100 - L101 were not covered by tests


[warning] 104-105: req.go#L104-L105
Added lines #L104 - L105 were not covered by tests


[warning] 108-109: req.go#L108-L109
Added lines #L108 - L109 were not covered by tests

33 changes: 33 additions & 0 deletions req_interface_gen.go

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

100 changes: 100 additions & 0 deletions res.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,100 @@
package fiber

//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...)

Check warning on line 9 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L8-L9

Added lines #L8 - L9 were not covered by tests
}

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
}

func (r *DefaultRes) Attachment(filename ...string) {
r.ctx.Attachment(filename...)

Check warning on line 17 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L16-L17

Added lines #L16 - L17 were not covered by tests
}

func (r *DefaultRes) AutoFormat(body any) error {
return r.ctx.AutoFormat(body)

Check warning on line 21 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L20-L21

Added lines #L20 - L21 were not covered by tests
}

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)

Check warning on line 29 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L28-L29

Added lines #L28 - L29 were not covered by tests
}

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

Check warning on line 33 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L32-L33

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

func (r *DefaultRes) Download(file string, filename ...string) error {
return r.ctx.Download(file, filename...)

Check warning on line 37 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L36-L37

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

func (r *DefaultRes) Format(handlers ...ResFmt) error {
return r.ctx.Format(handlers...)

Check warning on line 41 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L40-L41

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

func (r *DefaultRes) Get(key string, defaultValue ...string) string {
return r.ctx.GetRespHeader(key, defaultValue...)

Check warning on line 45 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L44-L45

Added lines #L44 - L45 were not covered by tests
}

func (r *DefaultRes) JSON(body any, ctype ...string) error {
return r.ctx.JSON(body, ctype...)

Check warning on line 49 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L48-L49

Added lines #L48 - L49 were not covered by tests
}

func (r *DefaultRes) JSONP(data any, callback ...string) error {
return r.ctx.JSONP(data, callback...)

Check warning on line 53 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L52-L53

Added lines #L52 - L53 were not covered by tests
}

func (r *DefaultRes) Links(link ...string) {
r.ctx.Links(link...)

Check warning on line 57 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L56-L57

Added lines #L56 - L57 were not covered by tests
}

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 {
return r.ctx.Render(name, bind, layouts...)

Check warning on line 65 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L64-L65

Added lines #L64 - L65 were not covered by tests
}

func (r *DefaultRes) Send(body []byte) error {
return r.ctx.Send(body)

Check warning on line 69 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L68-L69

Added lines #L68 - L69 were not covered by tests
}

func (r *DefaultRes) SendFile(file string, config ...SendFile) error {
return r.ctx.SendFile(file, config...)

Check warning on line 73 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L72-L73

Added lines #L72 - L73 were not covered by tests
}

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) Set(key, val string) {
r.ctx.Set(key, val)

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) Status(status int) Res {
r.ctx.Status(status)
return r

Check warning on line 86 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L84-L86

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

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

Check warning on line 91 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L89-L91

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

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

Check warning on line 95 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L94-L95

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

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

Check warning on line 99 in res.go

View check run for this annotation

Codecov / codecov/patch

res.go#L98-L99

Added lines #L98 - L99 were not covered by tests
}
Comment on lines +4 to +100
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Add unit tests for the response API methods.

The static analysis indicates that the new response API methods lack test coverage. This is critical for ensuring the delegation pattern works correctly and maintaining reliability during future changes.

Would you like me to help generate comprehensive unit tests for these methods?

🧰 Tools
🪛 GitHub Check: codecov/patch

[warning] 8-9: res.go#L8-L9
Added lines #L8 - L9 were not covered by tests


[warning] 12-13: res.go#L12-L13
Added lines #L12 - L13 were not covered by tests

30 changes: 30 additions & 0 deletions res_interface_gen.go

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

Loading