JavaWebStack / JavaWebStack/web-framework
Less mess up potential when registering middleware and controllers by making the order of registration irrelevant
- 主要語言
- 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