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
Replace std::map<std::string, bool> method_state with a 32-bit
method_set bitmask. Public API now takes http_method enum values
instead of strings; is_allowed and get_allowed_methods are const
noexcept; sizeof(http_resource) collapses to vptr + uint32_t + padding.
The wire-string-to-enum decode happens once at the dispatch boundary
(webserver_impl::answer_to_connection) and the result is cached on
modded_request::method_enum so finalize_answer can ask is_allowed
without a per-request strcmp loop. Allow-header serialization moves
to enum-declaration order; the only in-tree assertion ("HEAD, POST")
is preserved by coincidence of head=1, post=2.
In-tree string callers (test/integ/basic.cpp, test/integ/ws_start_stop.cpp,
examples/allowing_disallowing_methods.cpp, examples/custom_error.cpp)
migrated to the typed API. resource_init and the std::map data member
are gone; http_resource.hpp drops <map>/<string>/<vector>/<utility>/
<iostream>, leaving only <memory> and httpserver/http_method.hpp.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
Copy file name to clipboardExpand all lines: specs/tasks/M4-handlers/TASK-021.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
Replace `http_resource`'s `std::map<std::string, bool> method_state` with a `method_set` bitmask, shrink `sizeof(http_resource)`, and make `is_allowed`/`get_allowed_methods` const.
9
9
10
10
**Action Items:**
11
-
-[] Replace `std::map<std::string, bool> method_state` with `method_set methods_allowed_;` member.
12
-
-[]`bool is_allowed(http_method m) const noexcept` returns `methods_allowed_.contains(m)`.
13
-
-[]`method_set get_allowed_methods() const noexcept` returns `methods_allowed_` by value.
14
-
-[]`void set_allowing(http_method m, bool allow) noexcept` (mutator stays non-const).
-[] Convert internal v1 callers that passed method names as strings to use `http_method` enum values; provide a string→enum helper if existing user-facing setters need to keep their string form.
11
+
-[x] Replace `std::map<std::string, bool> method_state` with `method_set methods_allowed_;` member.
12
+
-[x]`bool is_allowed(http_method m) const noexcept` returns `methods_allowed_.contains(m)`.
13
+
-[x]`method_set get_allowed_methods() const noexcept` returns `methods_allowed_` by value.
14
+
-[x]`void set_allowing(http_method m, bool allow) noexcept` (mutator stays non-const).
-[x] Convert internal v1 callers that passed method names as strings to use `http_method` enum values. The string-based public API (`set_allowing(const std::string&, bool)` / `is_allowed(const std::string&)` / vector-returning `get_allowed_methods()`) was removed outright on this branch (Decision 1 in plan). The wire-string-to-enum decode happens once at `webserver_impl::answer_to_connection` and the result is recorded on `modded_request::method_enum`; no public string-to-enum helper is shipped.
17
17
18
18
**Dependencies:**
19
19
- Blocked by: TASK-005
@@ -29,4 +29,4 @@ Replace `http_resource`'s `std::map<std::string, bool> method_state` with a `met
0 commit comments