Commit d23d1a5
TASK-024: register_path / register_prefix split (GREEN)
Replaces the positional `bool family` parameter on register_resource
with a named-API choice between exact and prefix matching. Public
surface on `webserver`:
- register_path(path, ptr) -- exact-match registration. Both
unique_ptr<T> and shared_ptr<http_resource>
overloads, returning void. The
unique_ptr<T> form is a templated
inline shim that funnels into the
shared_ptr overload (TASK-023's
pattern) so derived types resolve
unambiguously.
- register_prefix(path, ptr) -- prefix-match registration. Same
overload shape.
- register_resource(path, ptr) -- now [[deprecated]]; thin alias for
register_path. The 3-arg `bool
family` overloads are GONE.
- unregister_path(path) -- erase only an exact registration.
- unregister_prefix(path) -- erase only a prefix registration.
- unregister_resource(path) -- kind-agnostic convenience; calls
both unregister_path and
unregister_prefix (idempotent).
Implementation moves the validation/insertion logic into a private
register_impl_(path, res, family) helper so the family flag only lives
in one place. The same is done for unregister: unregister_impl_ builds
the http_endpoint with the correct family flag (so the erase actually
finds the original key) and only touches the registered_resources_str
fast-path map for non-family entries (the str map only ever held
exact registrations -- this fixes a latent erase bug where
unregister_resource called .erase(string) on a map<http_endpoint,...>).
The single_resource validation now reads "must be registered via
register_prefix" rather than "must be marked as family"; the
deprecated register_resource forwarder calls register_path, so a
single_resource caller doing register_resource("/", sp) now correctly
throws -- they must call register_prefix("/", sp).
Acceptance criteria:
- `grep -E 'register_resource\([^)]+,\s*bool\s' src/httpserver/*.hpp`
returns no results: the bool-family overloads are deleted.
- The new test TU pins both kinds at runtime (prefix matches a
longer URL; exact does not; parameterized exact path binds {id};
unregister_* and the umbrella unregister_resource alias all 404
after removal; the deprecated register_resource forwarder still
serves and behaves like register_path).
- All 34 testsuite entries pass under `make check -j1`.
Call sites updated in this commit:
- examples/*: register_resource(p, ptr, true) -> register_prefix(p, ptr).
Other examples (which used register_resource for exact match) are
renamed to register_path to avoid -Werror on the new
[[deprecated]] forwarder.
- test/integ/*: same treatment. The smartptr unit test still
exercises the deprecated forwarder (that is its purpose), so it
silences -Wdeprecated-declarations file-wide.
- examples/url_registration.cpp gains a "/family" prefix showcase
and uses register_path / register_prefix throughout to model the
new API surface for users.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 7d7146b commit d23d1a5
47 files changed
Lines changed: 453 additions & 360 deletions
File tree
- examples
- src
- httpserver
- test
- integ
- unit
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
35 | 35 | | |
36 | 36 | | |
37 | 37 | | |
38 | | - | |
| 38 | + | |
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
90 | 90 | | |
91 | 91 | | |
92 | 92 | | |
93 | | - | |
| 93 | + | |
94 | 94 | | |
95 | 95 | | |
96 | 96 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
42 | | - | |
| 42 | + | |
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
52 | 52 | | |
53 | 53 | | |
54 | 54 | | |
55 | | - | |
| 55 | + | |
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
54 | | - | |
| 54 | + | |
55 | 55 | | |
56 | 56 | | |
57 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
53 | | - | |
| 53 | + | |
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
77 | | - | |
| 77 | + | |
78 | 78 | | |
79 | 79 | | |
80 | 80 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
67 | | - | |
| 66 | + | |
| 67 | + | |
68 | 68 | | |
69 | 69 | | |
70 | 70 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
157 | 157 | | |
158 | 158 | | |
159 | 159 | | |
160 | | - | |
161 | | - | |
| 160 | + | |
| 161 | + | |
162 | 162 | | |
163 | 163 | | |
164 | 164 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
0 commit comments