You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: specs/tasks/M5-routing-lifecycle/TASK-051.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -8,12 +8,12 @@
8
8
Add a per-resource scope to the hook bus so a hook can be attached to one route instead of every request. Required to give #273-style early-413 a per-route flavor (different size caps per endpoint), to put per-route timing in `response_sent`, etc.
9
9
10
10
**Action Items:**
11
-
-[] Add `http_resource::add_hook(hook_phase, ...)` overloads — but ONLY for phases that fire after route resolution: `before_handler`, `handler_exception`, `after_handler`, `response_sent`, `request_completed`. Passing any earlier phase throws `std::invalid_argument` with a message naming the phase and the constraint.
12
-
-[] Add per-resource storage on `http_resource`: `std::array<std::vector<std::function<...>>, hook_phase::count_>` (most slots unused per the constraint above, but the array shape simplifies indexed access) + `std::array<std::atomic<bool>, hook_phase::count_> any_hooks_` + `std::shared_mutex hook_table_mutex_`. Memory footprint is a fixed-size array of empty vectors; revisit if TASK-039's `sizeof(http_resource)` budget is tight (a single `std::vector` of `std::pair<hook_phase, function>` is the fallback if so).
13
-
-[] In `webserver_impl::dispatch_resource_handler`, fire the per-route hook chain at each of the five applicable phases AFTER the server-wide chain at that phase, BEFORE checking for a server-wide short-circuit's result. (If server-wide short-circuited, do NOT run per-route — the response is already fixed.)
14
-
-[] In `webserver_impl::request_completed`, locate the resource that handled the request (carried on `modded_request` as a `weak_ptr<http_resource>` populated at dispatch time) and fire its `request_completed` per-route chain after the server-wide one. If the resource was unregistered between dispatch and completion, the `lock()` returns null and the per-route chain is skipped.
15
-
-[] Lock order: `route_table_mutex_` (already held by dispatch) → resource's `hook_table_mutex_` → server-wide `hook_table_mutex_`. Documented in `specs/architecture/05-cross-cutting.md` §5.6 and verified by TSan.
16
-
-[]`hook_handle` returned by `http_resource::add_hook` carries the same RAII semantics as the server-wide handle — destruction removes the registration. The handle holds a `weak_ptr<http_resource>`; if the resource is destroyed before the handle, `remove()` is a no-op.
11
+
-[x] Add `http_resource::add_hook(hook_phase, ...)` overloads — but ONLY for phases that fire after route resolution: `before_handler`, `handler_exception`, `after_handler`, `response_sent`, `request_completed`. Passing any earlier phase throws `std::invalid_argument` with a message naming the phase and the constraint.
12
+
-[x] Add per-resource storage on `http_resource`: `std::array<std::vector<std::function<...>>, hook_phase::count_>` (most slots unused per the constraint above, but the array shape simplifies indexed access) + `std::array<std::atomic<bool>, hook_phase::count_> any_hooks_` + `std::shared_mutex hook_table_mutex_`. Memory footprint is a fixed-size array of empty vectors; revisit if TASK-039's `sizeof(http_resource)` budget is tight (a single `std::vector` of `std::pair<hook_phase, function>` is the fallback if so).
13
+
-[x] In `webserver_impl::dispatch_resource_handler`, fire the per-route hook chain at each of the five applicable phases AFTER the server-wide chain at that phase, BEFORE checking for a server-wide short-circuit's result. (If server-wide short-circuited, do NOT run per-route — the response is already fixed.)
14
+
-[x] In `webserver_impl::request_completed`, locate the resource that handled the request (carried on `modded_request` as a `weak_ptr<http_resource>` populated at dispatch time) and fire its `request_completed` per-route chain after the server-wide one. If the resource was unregistered between dispatch and completion, the `lock()` returns null and the per-route chain is skipped.
15
+
-[x] Lock order: `route_table_mutex_` (already held by dispatch) → resource's `hook_table_mutex_` → server-wide `hook_table_mutex_`. Documented in `specs/architecture/05-cross-cutting.md` §5.6 and verified by TSan.
16
+
-[x]`hook_handle` returned by `http_resource::add_hook` carries the same RAII semantics as the server-wide handle — destruction removes the registration. The handle holds a `weak_ptr<http_resource>`; if the resource is destroyed before the handle, `remove()` is a no-op.
0 commit comments