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

feat: groups #728

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

feat: groups #728

wants to merge 3 commits into from

Conversation

danielgtaylor
Copy link
Owner

@danielgtaylor danielgtaylor commented Feb 16, 2025

This PR adds a new Group struct & feature that takes the functionality of the excellent https://github.com/cardinalby/hureg library and ports it into Huma's core. Basic functionality looks like this:

grp := huma.NewGroup(api, "/v1")
grp.UseMiddleware(authMiddleware)

huma.Get(grp, "/users", func(ctx context.Context, input *struct{}) ([]User, error) {
	// ...
})

Check out the included docs for more info!

Related to #719.
Fixes #489.

@Copilot Copilot bot review requested due to automatic review settings February 16, 2025 01:09
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.

Copilot reviewed 5 out of 5 changed files in this pull request and generated 1 comment.

Comments suppressed due to low confidence (1)

docs/docs/features/middleware.md:204

  • The phrase 'the API instance' should be corrected to 'list of middleware'.
-   [`huma.Middlewares`](https://pkg.go.dev/github.com/danielgtaylor/huma/v2#Middlewares) the API instance

docs/docs/features/groups.md Outdated Show resolved Hide resolved
Copy link

codecov bot commented Feb 16, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 92.87%. Comparing base (169da69) to head (cce8262).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #728      +/-   ##
==========================================
+ Coverage   92.78%   92.87%   +0.08%     
==========================================
  Files          22       23       +1     
  Lines        5062     5124      +62     
==========================================
+ Hits         4697     4759      +62     
  Misses        314      314              
  Partials       51       51              

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

@nutgood
Copy link

nutgood commented Feb 18, 2025

This is exactly what we needed ! Thanks @danielgtaylor.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Suggestion: groups and sub-routing
2 participants