Feature Request: Automatic HEAD request handling
まだ誰も着手していません。
評価
調査の方向性
ルート登録のエントリーポイントである e.GET() から開始し、提案されている middleware.AutoHead() アプローチと比較してください。既存のルーターとルート登録の動作を確認し、明示的な HEAD ルートが存在しない場合に自動的な HEAD 処理がどのように機能すべきかを判断してください。GET ルートがレスポンスボディを省略して HEAD リクエストに応答し、明示的な HEAD の動作を変更しないことを完了条件とします。
索引モデルが issue の本文から書いたものです。
説明
Currently, Echo requires explicit HEAD route registration for every GET route. Some other frameworks like Fiber, Express and Fastify handle this automatically. According to HTTP semantics, HEAD should behave identically to GET except that the response body is omitted. Automatically supporting HEAD for GET routes aligns with this expectation and reduces boilerplate.
Related: #654
Proposal
Add automatic HEAD handling for GET routes when no explicit HEAD route is registered.
Implementation Options
Option 1: Middleware approach
e := echo.New()
e.Use(middleware.AutoHead())
Pros:
- Opt-in
- No changes to core routing
- Simple implementation
Cons:
- Must be registered last in the middleware chain. Otherwise, middlewares registered after it will not execute for HEAD requests, since the middleware directly invokes the handler and bypasses the remaining chain
I've already implemented this approach, but after testing I realized the middleware ordering requirement makes it less convenient and more error-prone.
Option 2: Core integration
Auto-register HEAD routes during e.GET() calls, controlled by config :
e := echo.New()
e.AutoHead = true
Default value could remain false to avoid breaking existing behavior.
Pros:
- No middleware ordering constraints
- Slightly better performance, since re-routing is avoided
Cons:
- Requires changes to core Echo router/route registration
Questions
- Would the Echo team be interested in this functionality?
- If so, which implementation approach would be preferred: middleware or core integration? Would you consider a PR for either approach?
- 主要言語
- Go
- スター
- 32.7k
- フォーク
- 2.8k
- 平均マージ
- 9時間 39分
- マージ済み PR(30日)
- 6
コントリビューションガイド
このリポジトリのコントリビューションガイドは索引されていません
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
labstack/echo のほかの issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 65/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 68/100
-
難易度 3/5 1〜2日 初心者へのやさしさ 74/100
-
難易度 5/5 1週間以上 初心者へのやさしさ 35/100
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
-
acceptance-tests phase-coding schema-coverage testing triaged
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100
-
難易度 2/5 1〜3時間 初心者へのやさしさ 75/100