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