这是indexloc提供的服务,不要输入任何密码
Skip to content

feat!: refactor middlewares to separate init from run #832

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

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

costela
Copy link
Contributor

@costela costela commented May 27, 2025

This is a POC PR for #831. See the issue for more details.

Fixes #831

@Copilot Copilot AI review requested due to automatic review settings May 27, 2025 09:07
Copy link
Contributor

@Copilot Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR refactors how middleware functions are defined and executed in the huma API by separating initialization from runtime execution. The changes update the middleware function signatures across production and test files, ensuring that middleware now follows the pattern func(next) func(ctx) for improved composability.

Reviewed Changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated no comments.

Show a summary per file
File Description
huma_test.go Updated middleware function signature in tests
group_test.go Updated middleware function signature in group tests
group.go Adjusted UseMiddleware signature to use the Middleware type
chain.go Refactored middleware chaining to call Middleware functions directly
api_test.go Updated middleware usage pattern in API tests
api.go Updated UseMiddleware signature in the API interface and implementation
adapters/humafiber/humafiber_context_test.go Updated middleware signature in fiber adapter tests
adapters/adapters_test.go Updated middleware signature in adapter tests

Copy link

codecov bot commented May 27, 2025

Codecov Report

Attention: Patch coverage is 80.00000% with 1 line in your changes missing coverage. Please review.

Project coverage is 93.03%. Comparing base (21709a0) to head (ae01ae5).
Report is 14 commits behind head on main.

Files with missing lines Patch % Lines
autopatch/autopatch.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #832      +/-   ##
==========================================
- Coverage   93.08%   93.03%   -0.05%     
==========================================
  Files          23       23              
  Lines        5307     5386      +79     
==========================================
+ Hits         4940     5011      +71     
- Misses        314      319       +5     
- Partials       53       56       +3     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@danielgtaylor danielgtaylor added the v3-ideas Ideas for a breaking version change label Jun 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
v3-ideas Ideas for a breaking version change
Projects
None yet
Development

Successfully merging this pull request may close these issues.

proposal: change Middlewares to split per-request ctx
2 participants