Skip to content

Commit d6a2728

Browse files
etrclaude
andcommitted
refactor: split webserver.hpp (845 → 498) into routes/ws/hooks
Step 5 of the FILE_LOC_MAX ratchet. Three concern-grouped sibling sub-headers, each included from inside the webserver class body via the same in-class-body #include pattern used for http_request_auth.hpp and webserver_impl_dispatch.hpp: webserver_routes.hpp register_path / register_prefix / register_resource (templated + shared_ptr overloads), the on_* shortcuts (on_get, on_post, on_put, on_delete, on_patch, on_options, on_head), the table-driven route() overloads, and the matching unregister_path / unregister_prefix / unregister_resource. webserver_websocket.hpp register_ws_resource (templated + shared_ptr) and unregister_ws_resource. webserver_hooks.hpp add_hook (11 overloads, one per hook_phase) and the HTTPSERVER_COMPILATION-gated make_hook_handle_ factory. Each sub-header gates itself on SRC_HTTPSERVER_WEBSERVER_HPP_INSIDE_CLASS_, which webserver.hpp #define's before the include block and #undef's after, so standalone inclusion raises a #error. The headers are installed (nobase_include_HEADERS) so consumers see the declarations transitively through <httpserver.hpp> -> webserver.hpp -> sibling. They are NOT added to the umbrella's sub-header list because the inner gate forbids standalone inclusion. Public API order is preserved verbatim. No ABI change, no semantic change. The fully-qualified @ref tags inside webserver_hooks.hpp (@ref httpserver::hook_phase / @ref httpserver::hook_handle ...) are unchanged in target; only the textual form needed qualification because doxygen parses sub-headers without the enclosing namespace context. FILE_LOC_MAX stays at 2700 -- webserver.cpp (2673) still pins it. Offender list down to two files. Verification: make check 51/51 PASS (includes hygiene, install-layout, doxygen, examples, readme, release-notes) ./scripts/check-file-size.sh PASS at FILE_LOC_MAX=2700 Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent 7fc443a commit d6a2728

6 files changed

Lines changed: 492 additions & 363 deletions

File tree

scripts/check-file-size.sh

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232
# Current offenders above the long-term 500-line target (2026-05-22):
3333
# src/webserver.cpp 2673
3434
# src/http_request.cpp 1175
35-
# src/httpserver/webserver.hpp 845
3635
#
3736
# FILE_LOC_MAX is pinned by the largest unfixed file (webserver.cpp at
3837
# 2673), so it cannot drop until the top offender is decomposed. The

src/Makefile.am

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ libhttpserver_la_SOURCES = string_utilities.cpp webserver.cpp http_utils.cpp fil
3030
# Detail headers (httpserver/detail/*.hpp) live here so they cannot leak to
3131
# downstream consumers — the public surface comes in through <httpserver.hpp>.
3232
noinst_HEADERS = httpserver/string_utilities.hpp httpserver/detail/modded_request.hpp httpserver/detail/http_endpoint.hpp httpserver/detail/body.hpp httpserver/detail/webserver_impl.hpp httpserver/detail/webserver_impl_dispatch.hpp httpserver/detail/connection_state.hpp httpserver/detail/http_request_impl.hpp httpserver/detail/route_entry.hpp httpserver/detail/lambda_resource.hpp httpserver/detail/radix_tree.hpp httpserver/detail/route_cache.hpp gettext.h
33-
nobase_include_HEADERS = httpserver.hpp httpserver/body_kind.hpp httpserver/constants.hpp httpserver/create_webserver.hpp httpserver/create_test_request.hpp httpserver/webserver.hpp httpserver/websocket_handler.hpp httpserver/http_utils.hpp httpserver/ip_representation.hpp httpserver/file_info.hpp httpserver/http_request.hpp httpserver/http_request_auth.hpp httpserver/http_response.hpp httpserver/http_resource.hpp httpserver/feature_unavailable.hpp httpserver/iovec_entry.hpp httpserver/http_arg_value.hpp httpserver/http_method.hpp httpserver/hook_phase.hpp httpserver/hook_action.hpp httpserver/hook_handle.hpp httpserver/hook_context.hpp
33+
nobase_include_HEADERS = httpserver.hpp httpserver/body_kind.hpp httpserver/constants.hpp httpserver/create_webserver.hpp httpserver/create_test_request.hpp httpserver/webserver.hpp httpserver/webserver_routes.hpp httpserver/webserver_websocket.hpp httpserver/webserver_hooks.hpp httpserver/websocket_handler.hpp httpserver/http_utils.hpp httpserver/ip_representation.hpp httpserver/file_info.hpp httpserver/http_request.hpp httpserver/http_request_auth.hpp httpserver/http_response.hpp httpserver/http_resource.hpp httpserver/feature_unavailable.hpp httpserver/iovec_entry.hpp httpserver/http_arg_value.hpp httpserver/http_method.hpp httpserver/hook_phase.hpp httpserver/hook_action.hpp httpserver/hook_handle.hpp httpserver/hook_context.hpp
3434

3535
AM_CXXFLAGS += -fPIC -Wall
3636

0 commit comments

Comments
 (0)