danielgtaylor / danielgtaylor/huma

Improve middleware support for route groups

Open
#691 3 comments 2 reactions 0 assignees View on GitHub
help wanted question
Dominant language
Go
Stars
4.4k
Forks
285
Avg merge
40m
Merged PRs (30d)
1

Description

First of all, thank you for the great work @danielgtaylor. Huma has a few clever solutions and features that I miss from other frameworks. However, it has some cons as well. It tries to be router agnostic but enforces structures that are not suitable for all.

I was trying to use an existing middleware and discovered several issues related to route groups. If I use a chi middleware it gets applied for all the routes, if I define a route group, it breaks the docs ... all of this could be fixed with workarounds and hacks but I would expect more flexibility from a framework like this. This is definitely something that bothers others as well, I quickly found an [issue](https://github.com/danielgtaylor/huma/issues/684) and an [extension](https://github.com/cardinalby/hureg) that address the same problems. This blocks me from using this framework for bigger projects.

Unfortunately, I don't have a working proposal on how to fix all of this, maybe the community should consider merging Hureg into Huma

Edit: I know if I would rewrite those middlewares and attach them to each route one by one my issue would be solved, and probably that's what I will do, but I don't like to repeat myself, those middleware work, and I will less likely forget to attach them if I attach them to the whole group and not for each endpoint.

Contributor guide

No contributing guide indexed for this repository

Research direction

No source files or tests are named. Start by reviewing issue 684 and the Hureg extension linked in the report, then trace how Huma represents route groups, middleware, and generated documentation; done means agreeing on a flexible design that preserves correct middleware scope without breaking the docs.

Written by the indexing model from the issue text.

Assessment

Tech stack
go
Domain
api, backend-api-design
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Needs clarification
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.