JavaWebStack / JavaWebStack/web-framework
Less mess up potential when registering middleware and controllers by making the order of registration irrelevant
- Dominant language
- Java
- Stars
- 0
- Forks
- 0
- PR merge metrics
- No merged PRs in 30d
Description
**Is your feature request related to a problem? Please describe.**
When the controllers are registered before the middlewares the middlewares don't work or kick into action. I was confused about this and this is a potential for frustration and wasted time debugging.
**Describe the solution you'd like**
The order of registration becomes irrelevant.
**Describe alternatives you've considered**
Providing informative information via the logger on at least warning level.
**Additional context**
Working code sample:
```
public void setupServer(HTTPServer httpServer) {
httpServer.middleware("auth", new AuthenticationMiddleware());
httpServer.beforeAny("/api", new AuthenticationMiddleware());
httpServer.controller(HttpController.class, RootController.class.getPackage());
}
```
Unexpetedly broken sample:
```
public void setupServer(HTTPServer httpServer) {
httpServer.controller(HttpController.class, RootController.class.getPackage());
httpServer.middleware("auth", new AuthenticationMiddleware());
httpServer.beforeAny("/api", new AuthenticationMiddleware());
}
```
Contributor guide
No contributing guide indexed for this repository
Research direction
Start at the HTTPServer registration entry points shown in setupServer: controller, middleware, and beforeAny. Trace how registration order affects middleware activation, then define completion as both code samples applying the middleware equivalently; consider the requested warning log as an alternative if order independence is not feasible.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100