Commit beb0811
TASK-030: _handler suffix renames + explicit webserver ctor
Rename the three error-page setters on `create_webserver` from the
`_resource` to the `_handler` suffix, retype them to take
`std::function<http_response(const http_request&)>` (return by value,
matching the on_* family from TASK-025/026), and mark
`webserver(const create_webserver&)` `explicit` so a stray
`webserver ws = some_create_webserver;` no longer compiles.
- `not_found_resource` -> `not_found_handler`
- `method_not_allowed_resource` -> `method_not_allowed_handler`
- `internal_error_resource` -> `internal_error_handler`
Surface changes:
- Drop the `render_ptr` typedef; introduce a public `error_handler`
typedef in `create_webserver.hpp` to keep the field/setter parameter
types in sync.
- Adapters in `webserver_impl::{not_found,method_not_allowed,
internal_error}_page` now wrap the by-value handler result via
`std::make_shared<http_response>(...)`; `force_our` semantics on
`internal_error_page` preserved.
- Constructor doc-comment replaced ("Keeping this non explicit on
purpose...") with a PRD-NAM-REQ-004 trace.
Compile-time sentinel:
- New `test/unit/create_webserver_explicit_test.cpp` pins both
guarantees via static_asserts:
* `!is_convertible_v<create_webserver, webserver>` (negative),
* `is_constructible_v<webserver, const create_webserver&>` (positive),
* positive SFINAE detectors for the three `_handler`-suffixed
setters with the by-value handler signature,
* negative SFINAE detectors confirming the `_resource`-suffixed
setters are gone.
- Wired into `test/Makefile.am` with empty LDADD (header-only compile
test, following the `webserver_pimpl` precedent).
Mechanical migration across the call-site graph:
- 250 implicit copy-init sites converted to direct-init
(`webserver ws = create_webserver(...);` -> `webserver ws{...};`)
across 45 files in `test/`, `examples/`, and `README.md`.
- All 11 setter-call sites renamed.
- 6 error-handler function/lambda bodies retargeted from
`shared_ptr<http_response>` to `http_response` by value
(custom_error.cpp, ws_start_stop.cpp, basic.cpp, create_webserver_test.cpp).
- README error-page documentation updated to reflect the new
`std::function<http_response(const http_request&)>` signature.
Acceptance gates (all empty as required):
- `grep -rE '(not_found|method_not_allowed|internal_error)_resource'
src/httpserver/*.hpp`
- `grep -rEn '\brender_ptr\b' src/ test/ examples/`
- `grep -rEn '\bwebserver\s+\w+\s*=\s*(httpserver::|ht::)?create_webserver\b'
test/ examples/ README.md`
- `grep -n 'NOLINT(runtime/explicit)' src/httpserver/webserver.hpp`
All 41 tests pass (40 prior + 1 new sentinel). cpplint clean on every
touched file.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f2f1aea commit beb0811
55 files changed
Lines changed: 572 additions & 442 deletions
File tree
- examples
- specs/tasks/M5-routing-lifecycle
- 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.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
33 | | - | |
| 33 | + | |
34 | 34 | | |
35 | 35 | | |
36 | 36 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
87 | 87 | | |
88 | 88 | | |
89 | 89 | | |
90 | | - | |
| 90 | + | |
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
36 | 36 | | |
37 | 37 | | |
38 | 38 | | |
39 | | - | |
| 39 | + | |
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
| 46 | + | |
47 | 47 | | |
48 | | - | |
| 48 | + | |
49 | 49 | | |
50 | 50 | | |
51 | 51 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
43 | 43 | | |
44 | 44 | | |
45 | 45 | | |
46 | | - | |
47 | | - | |
| 46 | + | |
| 47 | + | |
48 | 48 | | |
49 | 49 | | |
50 | 50 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
71 | 71 | | |
72 | 72 | | |
73 | 73 | | |
74 | | - | |
| 74 | + | |
75 | 75 | | |
76 | 76 | | |
77 | 77 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
56 | 56 | | |
57 | 57 | | |
58 | 58 | | |
59 | | - | |
| 59 | + | |
60 | 60 | | |
61 | | - | |
| 61 | + | |
62 | 62 | | |
63 | 63 | | |
64 | 64 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
148 | 148 | | |
149 | 149 | | |
150 | 150 | | |
151 | | - | |
| 151 | + | |
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
155 | | - | |
| 155 | + | |
156 | 156 | | |
157 | 157 | | |
158 | 158 | | |
| |||
0 commit comments