Commit 15f8083
refactor: split webserver.cpp 7-way + drop FILE_LOC_MAX to 500
Final step of the ratchet. The 2673-line webserver.cpp is decomposed
along the section markers already in the file into seven new TUs, each
focused on a single concern and well below the 500-line target. The
residual webserver.cpp keeps ctors / dtors / signal helpers / hooks
machinery and lands at 464 lines.
src/detail/webserver_setup.cpp 437 MHD option array
builders (add_base /
tls / gnutls / extended /
https_extra) + start-flag
composers, daemon lifecycle
(start, is_running, stop,
run, run_wait, get_fdset,
get_timeout, add_connection),
and block_ip / unblock_ip.
src/detail/webserver_register.cpp 360 register_path /
register_prefix /
register_resource (incl.
the shared register_impl_
funnel and detail::
register_v2_route mirror)
+ unregister_impl_ /
unregister_path /
unregister_prefix /
unregister_resource. Uses
the shared route_tier
helper.
src/detail/webserver_routes.cpp 411 on_methods_ funnel + the
seven on_* shortcuts +
both route() overloads +
the detail-namespace
lambda_shim helpers
(prepare_or_create_lambda_shim,
commit_handlers_to_shim,
insert_fresh_v1_entries,
upsert_v2_table_entry +
its sub-helpers). Uses
the shared route_tier.
src/detail/webserver_callbacks.cpp 477 MHD trampolines registered
with libmicrohttpd
(request_completed,
connection_notify, policy_
callback, error_log,
access_log, uri_log,
unescaper_func, PSK/SNI
cred handlers) + the
post_iterator family
(handle_post_form_arg,
setup_new_upload_file_info,
manage_upload_stream,
process_file_upload, the
post_iterator trampoline).
src/detail/webserver_websocket.cpp 227 HAVE_WEBSOCKET-gated TU.
decode_websocket_buffer
static helper +
upgrade_handler MHD
callback + the anonymous-
namespace handshake
helpers.
src/detail/webserver_dispatch.cpp 460 Dispatch support services:
not_found_page /
method_not_allowed_page /
internal_error_page /
log_dispatch_error /
run_internal_error_handler_safely
+ invalidate_route_cache +
lookup_v2 (the v2 3-tier
walk) + the route-table
helpers
(lookup_route_cache,
scan_regex_routes,
store_route_cache,
apply_extracted_params,
resolve_resource_for_request,
apply_auth_short_circuit,
dispatch_resource_handler).
src/detail/webserver_request.cpp 488 Request lifecycle:
should_skip_auth + its
normalize_path helper +
requests_answer_first_step /
requests_answer_second_step,
materialize_response /
decorate_mhd_response /
get_raw_response_with_fallback,
the websocket-upgrade
dispatch helpers
(validate_websocket_handshake,
complete_websocket_upgrade,
try_handle_websocket_upgrade),
materialize_and_queue_response,
finalize_answer,
complete_request,
resolve_method_callback,
and the answer_to_connection
entrypoint.
src/webserver.cpp 464 Residual: license / includes
/ signal helpers
(catcher, ignore_sigpipe)
/ webserver_impl ctor +
dtor / webserver ctor +
dtor + features() +
stop_and_wait() / the
TASK-045 hook bus
(register_hook_impl
anonymous-namespace helper
+ make_hook_handle_ +
the eleven add_hook
overloads).
One small companion header was extracted to share state across TUs:
src/httpserver/detail/route_tier.hpp Hoists the route_tier_kind
enum + route_tier_result
struct + classify_route_tier
from an anonymous namespace
in webserver.cpp into a
detail header. Both
webserver_register.cpp and
webserver_routes.cpp call
classify_route_tier; an
anonymous-namespace
definition no longer
suffices once the TU is
split. Marked inline so
the ODR holds across
translation units.
normalize_path (and its apply_normalized_segment helper) — formerly
file-scope statics in webserver.cpp — co-locate with their only caller
(webserver_impl::should_skip_auth) in webserver_request.cpp.
FILE_LOC_MAX drops from 2700 to 500, the long-term project target.
The header comment in scripts/check-file-size.sh records the seven
ratchet steps that drove it down.
Verification:
make check ALL PASS (includes hygiene,
install-layout, doxygen, examples,
readme, release-notes)
./scripts/check-file-size.sh PASS at FILE_LOC_MAX=500
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 39dd971 commit 15f8083
12 files changed
Lines changed: 2932 additions & 2220 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
610 | 610 | | |
611 | 611 | | |
612 | 612 | | |
613 | | - | |
| 613 | + | |
614 | 614 | | |
615 | 615 | | |
616 | 616 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
33 | | - | |
| 32 | + | |
| 33 | + | |
34 | 34 | | |
35 | | - | |
36 | | - | |
37 | | - | |
38 | | - | |
39 | | - | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
40 | 48 | | |
41 | 49 | | |
42 | 50 | | |
43 | 51 | | |
44 | 52 | | |
45 | 53 | | |
46 | 54 | | |
47 | | - | |
| 55 | + | |
48 | 56 | | |
49 | 57 | | |
50 | 58 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
25 | 25 | | |
26 | 26 | | |
27 | 27 | | |
28 | | - | |
| 28 | + | |
29 | 29 | | |
30 | 30 | | |
31 | 31 | | |
32 | | - | |
| 32 | + | |
33 | 33 | | |
34 | 34 | | |
35 | 35 | | |
| |||
0 commit comments