Commit ced6190
Move HEAD route creation into Grape::Router::Route#to_head
`Endpoint#mount_in` built the HEAD variant of a GET route inline: dup the
route, flip its request method, then apply and append it. Duplicating a
route and turning it into a HEAD request is the route's own concern, not
the endpoint's.
Add `Route#to_head`, which returns a fresh HEAD copy of the route, and
demote `convert_to_head_request!` to `protected` now that `to_head` is
its only caller. `mount_in` keeps the decision of whether to add a HEAD
route (the `do_not_route_head` setting and the GET check) and just calls
`route.to_head.apply(self)`.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent 99f42ae commit ced6190
2 files changed
Lines changed: 11 additions & 6 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
120 | 120 | | |
121 | 121 | | |
122 | 122 | | |
123 | | - | |
124 | | - | |
125 | | - | |
126 | | - | |
| 123 | + | |
127 | 124 | | |
128 | 125 | | |
129 | 126 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
19 | 19 | | |
20 | 20 | | |
21 | 21 | | |
22 | | - | |
23 | | - | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
24 | 26 | | |
25 | 27 | | |
26 | 28 | | |
| |||
43 | 45 | | |
44 | 46 | | |
45 | 47 | | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
46 | 54 | | |
47 | 55 | | |
48 | 56 | | |
| |||
0 commit comments