* enhance code imported by #3413
if it needs to check if the handler is nil, tie c.index shall
always ++
* test: refactor test context initialization and handler logic
- Remove an empty line in `TestContextInitQueryCache`
- Add `TestContextNext` function with tests for `Next` method behavior with no handlers, one handler, and multiple handlers
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
---------
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: zjj <zhong2plus@gmail.com>
This PR introduces a generic function, getTyped[T any], to simplify value retrieval in the Context struct. It replaces repetitive type assertions in the GetString GetBool etc. methods.
Co-authored-by: Maksim Konovalov <maksim.konovalov@vk.team>
Use assert.InDelta for float comparison with tolerance in TestContextGetFloat32
Remove unnecessary blank line in TestContextInitQueryCache
Replace anonymous struct with named contextKey type in TestContextWithFallbackValueFromRequestContext
Update context key handling in TestContextWithFallbackValueFromRequestContext to use contextKey type
* fixed#3404 2022-11-23
* up 2022-11-23
* refactor: refactor context handling and nil checks
- Refactor nil checks to improve readability in `context.go`
- Modify the control flow in `HandlerNames` and `Next` methods to continue on nil values before appending or invoking handlers in `context.go`
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* test: refactor context_test.go for clarity and efficiency
- Insert a `nil` value into the `HandlersChain` array in `context_test.go`
- Remove empty test functions in `context_test.go`
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
---------
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
Co-authored-by: Bo-Yi Wu <appleboy.tw@gmail.com>
* feat: ShouldBindBodyWith shortcut and change doc
* fix: yaml can parse json test case
* style: fix new test case in context_test.go
* chore: modify the code style to specify binding type
* chroe: gofmt modifies the code format
* Optimize the Copy method of the Context struct: using 'make' to initialize the map('cp.Keys') with a length of 'c.Keys'; avoiding repeatedly assiging the 'params' to 'context'.
* Using temporary variables to save c.Keys and c.Params to prevent them from changing during the copying process.
---------
Co-authored-by: huangzw <huangzw@hsmap.com>
* fix lack of escaping of filename in Content-Disposition
* add test for Content-Disposition filename escaping process
* fix filename escape bypass problem
fix backslashes before backquotes were not properly escaped problem.