JavaWebStack / JavaWebStack/web-framework

Less mess up potential when registering middleware and controllers by making the order of registration irrelevant

未关闭
#2 0 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看
enhancement
主要语言
Java
星标
0
派生
0
PR 合并指标
30 天内没有已合并 PR

描述

**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());
}
```

贡献指南

这个仓库没有索引到贡献指南

调研方向

从 setupServer 中显示的 HTTPServer 注册入口开始:controller、middleware 和 beforeAny。跟踪注册顺序如何影响 middleware 的激活,然后将完成标准定义为两个代码示例都以等效方式应用 middleware;如果无法实现与顺序无关,则将请求的警告日志作为替代方案考虑。

由索引模型根据 Issue 内容生成。

评估

技术栈
java
领域
backend
Issue 类型
功能
难度
4/5
预计耗时
3-5 天
活跃度
停滞
描述清晰度
基本清楚
新手友好度
35/100

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。