Skip to content

Commit 146c85d

Browse files
etrclaude
andcommitted
TASK-009: review-pass fixes (code-quality iter2: details→detail namespace)
Rename `httpserver::details` namespace → `httpserver::detail` across all remaining source/test files so the namespace name matches the renamed directory (per TASK-009 directory rename `src/{,httpserver/}details/` → `src/{,httpserver/}detail/`). Carried-over headers and CPPs that still qualified internal types as `httpserver::details::X` would otherwise fail to compile with the now-canonical `httpserver::detail` declarations. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
1 parent f4bb3d2 commit 146c85d

12 files changed

Lines changed: 51 additions & 51 deletions

src/deferred_response.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,12 +26,12 @@ struct MHD_Response;
2626

2727
namespace httpserver {
2828

29-
namespace details {
29+
namespace detail {
3030

3131
MHD_Response* get_raw_response_helper(void* cls, ssize_t (*cb)(void*, uint64_t, char*, size_t)) {
3232
return MHD_create_response_from_callback(MHD_SIZE_UNKNOWN, 1024, cb, cls, nullptr);
3333
}
3434

35-
} // namespace details
35+
} // namespace detail
3636

3737
} // namespace httpserver

src/detail/http_endpoint.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ using std::vector;
3737

3838
namespace httpserver {
3939

40-
namespace details {
40+
namespace detail {
4141

4242
http_endpoint::~http_endpoint() {
4343
}
@@ -162,6 +162,6 @@ bool http_endpoint::match(const http_endpoint& url) const {
162162
return regex_match(nn, re_url_normalized);
163163
}
164164

165-
} // namespace details
165+
} // namespace detail
166166

167167
} // namespace httpserver

src/http_resource.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,12 @@ void resource_init(std::map<std::string, bool>* method_state) {
4343
(*method_state)[MHD_HTTP_METHOD_PATCH] = true;
4444
}
4545

46-
namespace details {
46+
namespace detail {
4747

4848
std::shared_ptr<http_response> empty_render(const http_request&) {
4949
return std::make_shared<string_response>();
5050
}
5151

52-
} // namespace details
52+
} // namespace detail
5353

5454
} // namespace httpserver

src/httpserver/deferred_response.hpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -39,9 +39,9 @@ struct MHD_Response;
3939

4040
namespace httpserver {
4141

42-
namespace details {
42+
namespace detail {
4343
MHD_Response* get_raw_response_helper(void* cls, ssize_t (*cb)(void*, uint64_t, char*, size_t));
44-
} // namespace details
44+
} // namespace detail
4545

4646
template <class T>
4747
class deferred_response : public string_response {
@@ -67,7 +67,7 @@ class deferred_response : public string_response {
6767
~deferred_response() = default;
6868

6969
MHD_Response* get_raw_response() {
70-
return details::get_raw_response_helper(reinterpret_cast<void*>(this), &cb);
70+
return detail::get_raw_response_helper(reinterpret_cast<void*>(this), &cb);
7171
}
7272

7373
private:

src/httpserver/detail/http_endpoint.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@
3535

3636
namespace httpserver {
3737

38-
namespace details {
38+
namespace detail {
3939

4040
class http_resource;
4141

@@ -190,7 +190,7 @@ class http_endpoint {
190190
bool reg_compiled;
191191
};
192192

193-
} // namespace details
193+
} // namespace detail
194194

195195
} // namespace httpserver
196196
#endif // SRC_HTTPSERVER_DETAIL_HTTP_ENDPOINT_HPP_

src/httpserver/detail/modded_request.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333

3434
namespace httpserver {
3535

36-
namespace details {
36+
namespace detail {
3737

3838
struct modded_request {
3939
struct MHD_PostProcessor *pp = nullptr;
@@ -66,7 +66,7 @@ struct modded_request {
6666
}
6767
};
6868

69-
} // namespace details
69+
} // namespace detail
7070

7171
} // namespace httpserver
7272

src/httpserver/http_request.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ struct MHD_Connection;
5252

5353
namespace httpserver {
5454

55-
namespace details { struct modded_request; }
55+
namespace detail { struct modded_request; }
5656

5757
/**
5858
* Class representing an abstraction for an Http Request. It is used from classes using these apis to receive information through http protocol.
@@ -534,7 +534,7 @@ class http_request {
534534
}
535535

536536
friend class webserver;
537-
friend struct details::modded_request;
537+
friend struct detail::modded_request;
538538
};
539539

540540
std::ostream &operator<< (std::ostream &os, const http_request &r);

src/httpserver/http_resource.hpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ namespace httpserver { class http_response; }
4040

4141
namespace httpserver {
4242

43-
namespace details { std::shared_ptr<http_response> empty_render(const http_request& r); }
43+
namespace detail { std::shared_ptr<http_response> empty_render(const http_request& r); }
4444

4545
void resource_init(std::map<std::string, bool>* res);
4646

@@ -60,7 +60,7 @@ class http_resource {
6060
* @return A http_response object
6161
**/
6262
virtual std::shared_ptr<http_response> render(const http_request& req) {
63-
return details::empty_render(req);
63+
return detail::empty_render(req);
6464
}
6565

6666
/**

src/httpserver/webserver.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ namespace httpserver { class http_response; }
5959
#ifdef HAVE_WEBSOCKET
6060
namespace httpserver { class websocket_handler; }
6161
#endif // HAVE_WEBSOCKET
62-
namespace httpserver { namespace details { struct modded_request; } }
62+
namespace httpserver { namespace detail { struct modded_request; } }
6363

6464
struct MHD_Connection;
6565

@@ -277,12 +277,12 @@ class webserver {
277277
const bool no_alpn;
278278
const int client_discipline_level;
279279
std::shared_mutex registered_resources_mutex;
280-
std::map<details::http_endpoint, http_resource*> registered_resources;
280+
std::map<detail::http_endpoint, http_resource*> registered_resources;
281281
std::map<std::string, http_resource*> registered_resources_str;
282-
std::map<details::http_endpoint, http_resource*> registered_resources_regex;
282+
std::map<detail::http_endpoint, http_resource*> registered_resources_regex;
283283

284284
struct route_cache_entry {
285-
details::http_endpoint matched_endpoint;
285+
detail::http_endpoint matched_endpoint;
286286
http_resource* resource;
287287
};
288288
static constexpr size_t ROUTE_CACHE_MAX_SIZE = 256;
@@ -302,9 +302,9 @@ class webserver {
302302
std::map<std::string, websocket_handler*> registered_ws_handlers;
303303
#endif // HAVE_WEBSOCKET
304304

305-
std::shared_ptr<http_response> method_not_allowed_page(details::modded_request* mr) const;
306-
std::shared_ptr<http_response> internal_error_page(details::modded_request* mr, bool force_our = false) const;
307-
std::shared_ptr<http_response> not_found_page(details::modded_request* mr) const;
305+
std::shared_ptr<http_response> method_not_allowed_page(detail::modded_request* mr) const;
306+
std::shared_ptr<http_response> internal_error_page(detail::modded_request* mr, bool force_our = false) const;
307+
std::shared_ptr<http_response> not_found_page(detail::modded_request* mr) const;
308308
bool should_skip_auth(const std::string& path) const;
309309

310310
static void request_completed(void *cls,
@@ -331,17 +331,17 @@ class webserver {
331331
struct MHD_UpgradeResponseHandle *urh);
332332
#endif // HAVE_WEBSOCKET
333333

334-
MHD_Result requests_answer_first_step(MHD_Connection* connection, struct details::modded_request* mr);
334+
MHD_Result requests_answer_first_step(MHD_Connection* connection, struct detail::modded_request* mr);
335335

336336
MHD_Result requests_answer_second_step(MHD_Connection* connection,
337337
const char* method, const char* version, const char* upload_data,
338-
size_t* upload_data_size, struct details::modded_request* mr);
338+
size_t* upload_data_size, struct detail::modded_request* mr);
339339

340-
MHD_Result finalize_answer(MHD_Connection* connection, struct details::modded_request* mr, const char* method);
340+
MHD_Result finalize_answer(MHD_Connection* connection, struct detail::modded_request* mr, const char* method);
341341

342-
struct MHD_Response* get_raw_response_with_fallback(details::modded_request* mr);
342+
struct MHD_Response* get_raw_response_with_fallback(detail::modded_request* mr);
343343

344-
MHD_Result complete_request(MHD_Connection* connection, struct details::modded_request* mr, const char* version, const char* method);
344+
MHD_Result complete_request(MHD_Connection* connection, struct detail::modded_request* mr, const char* version, const char* method);
345345

346346
void invalidate_route_cache();
347347

src/webserver.cpp

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ void webserver::request_completed(void *cls, struct MHD_Connection *connection,
228228
std::ignore = connection;
229229
std::ignore = toe;
230230

231-
delete static_cast<details::modded_request*>(*con_cls);
231+
delete static_cast<detail::modded_request*>(*con_cls);
232232
}
233233

234234
bool webserver::register_resource(const std::string& resource, http_resource* hrm, bool family) {
@@ -240,18 +240,18 @@ bool webserver::register_resource(const std::string& resource, http_resource* hr
240240
throw std::invalid_argument("The resource should be '' or '/' and be marked as family when using a single_resource server");
241241
}
242242

243-
details::http_endpoint idx(resource, family, true, regex_checking);
243+
detail::http_endpoint idx(resource, family, true, regex_checking);
244244

245245
std::unique_lock registered_resources_lock(registered_resources_mutex);
246-
pair<map<details::http_endpoint, http_resource*>::iterator, bool> result = registered_resources.insert(map<details::http_endpoint, http_resource*>::value_type(idx, hrm));
246+
pair<map<detail::http_endpoint, http_resource*>::iterator, bool> result = registered_resources.insert(map<detail::http_endpoint, http_resource*>::value_type(idx, hrm));
247247

248248
if (result.second) {
249249
bool is_exact = !family && idx.get_url_pars().empty();
250250
if (is_exact) {
251251
registered_resources_str.insert(pair<string, http_resource*>(idx.get_url_complete(), result.first->second));
252252
}
253253
if (idx.is_regex_compiled()) {
254-
registered_resources_regex.insert(map<details::http_endpoint, http_resource*>::value_type(idx, hrm));
254+
registered_resources_regex.insert(map<detail::http_endpoint, http_resource*>::value_type(idx, hrm));
255255
}
256256
registered_resources_lock.unlock();
257257
invalidate_route_cache();
@@ -572,7 +572,7 @@ void webserver::invalidate_route_cache() {
572572

573573
void webserver::unregister_resource(const string& resource) {
574574
// family does not matter - it just checks the url_normalized anyhow
575-
details::http_endpoint he(resource, false, true, regex_checking);
575+
detail::http_endpoint he(resource, false, true, regex_checking);
576576
std::unique_lock registered_resources_lock(registered_resources_mutex);
577577

578578
// Invalidate cache while holding registered_resources_mutex to prevent
@@ -775,7 +775,7 @@ void* uri_log(void* cls, const char* uri, struct MHD_Connection *con) {
775775
std::ignore = cls;
776776
std::ignore = con;
777777

778-
auto mr = std::make_unique<details::modded_request>();
778+
auto mr = std::make_unique<detail::modded_request>();
779779
// MHD may invoke this callback with a null uri before the request line
780780
// has been parsed (e.g. port scans, half-open connections, or non-HTTP
781781
// traffic on the listening port). Treat that as an empty URI so the
@@ -830,7 +830,7 @@ MHD_Result webserver::post_iterator(void *cls, enum MHD_ValueKind kind,
830830
// Parameter needed to respect MHD interface, but not needed here.
831831
std::ignore = kind;
832832

833-
struct details::modded_request* mr = (struct details::modded_request*) cls;
833+
struct detail::modded_request* mr = (struct detail::modded_request*) cls;
834834

835835
if (!filename) {
836836
// There is no actual file, just set the arg key/value and return.
@@ -1016,23 +1016,23 @@ void webserver::upgrade_handler(void *cls, struct MHD_Connection* connection,
10161016
}
10171017
#endif // HAVE_WEBSOCKET
10181018

1019-
std::shared_ptr<http_response> webserver::not_found_page(details::modded_request* mr) const {
1019+
std::shared_ptr<http_response> webserver::not_found_page(detail::modded_request* mr) const {
10201020
if (not_found_resource != nullptr) {
10211021
return not_found_resource(*mr->dhr);
10221022
} else {
10231023
return std::make_shared<string_response>(std::string{constants::NOT_FOUND_ERROR}, http_utils::http_not_found);
10241024
}
10251025
}
10261026

1027-
std::shared_ptr<http_response> webserver::method_not_allowed_page(details::modded_request* mr) const {
1027+
std::shared_ptr<http_response> webserver::method_not_allowed_page(detail::modded_request* mr) const {
10281028
if (method_not_allowed_resource != nullptr) {
10291029
return method_not_allowed_resource(*mr->dhr);
10301030
} else {
10311031
return std::make_shared<string_response>(std::string{constants::METHOD_ERROR}, http_utils::http_method_not_allowed);
10321032
}
10331033
}
10341034

1035-
std::shared_ptr<http_response> webserver::internal_error_page(details::modded_request* mr, bool force_our) const {
1035+
std::shared_ptr<http_response> webserver::internal_error_page(detail::modded_request* mr, bool force_our) const {
10361036
if (internal_error_resource != nullptr && !force_our) {
10371037
return internal_error_resource(*mr->dhr);
10381038
} else {
@@ -1081,7 +1081,7 @@ bool webserver::should_skip_auth(const std::string& path) const {
10811081
return false;
10821082
}
10831083

1084-
MHD_Result webserver::requests_answer_first_step(MHD_Connection* connection, struct details::modded_request* mr) {
1084+
MHD_Result webserver::requests_answer_first_step(MHD_Connection* connection, struct detail::modded_request* mr) {
10851085
mr->dhr.reset(new http_request(connection, unescaper));
10861086
mr->dhr->set_file_cleanup_callback(file_cleanup_callback);
10871087

@@ -1106,7 +1106,7 @@ MHD_Result webserver::requests_answer_first_step(MHD_Connection* connection, str
11061106

11071107
MHD_Result webserver::requests_answer_second_step(MHD_Connection* connection, const char* method,
11081108
const char* version, const char* upload_data,
1109-
size_t* upload_data_size, struct details::modded_request* mr) {
1109+
size_t* upload_data_size, struct detail::modded_request* mr) {
11101110
if (0 == *upload_data_size) return complete_request(connection, mr, version, method);
11111111

11121112
if (mr->has_body) {
@@ -1134,7 +1134,7 @@ MHD_Result webserver::requests_answer_second_step(MHD_Connection* connection, co
11341134
return MHD_YES;
11351135
}
11361136

1137-
struct MHD_Response* webserver::get_raw_response_with_fallback(details::modded_request* mr) {
1137+
struct MHD_Response* webserver::get_raw_response_with_fallback(detail::modded_request* mr) {
11381138
try {
11391139
struct MHD_Response* raw = mr->dhrs->get_raw_response();
11401140
if (raw == nullptr) {
@@ -1159,7 +1159,7 @@ struct MHD_Response* webserver::get_raw_response_with_fallback(details::modded_r
11591159
}
11601160
}
11611161

1162-
MHD_Result webserver::finalize_answer(MHD_Connection* connection, struct details::modded_request* mr, const char* method) {
1162+
MHD_Result webserver::finalize_answer(MHD_Connection* connection, struct detail::modded_request* mr, const char* method) {
11631163
int to_ret = MHD_NO;
11641164

11651165
#ifdef HAVE_WEBSOCKET
@@ -1231,7 +1231,7 @@ MHD_Result webserver::finalize_answer(MHD_Connection* connection, struct details
12311231
fe = registered_resources_str.find(st_url);
12321232
if (fe == registered_resources_str.end()) {
12331233
if (regex_checking) {
1234-
details::http_endpoint endpoint(st_url, false, false, false);
1234+
detail::http_endpoint endpoint(st_url, false, false, false);
12351235

12361236
// Data needed for parameter extraction after match.
12371237
// On cache hit, we copy these while holding the cache lock
@@ -1256,7 +1256,7 @@ MHD_Result webserver::finalize_answer(MHD_Connection* connection, struct details
12561256

12571257
if (!found) {
12581258
// Cache miss — perform regex scan
1259-
map<details::http_endpoint, http_resource*>::iterator found_endpoint;
1259+
map<detail::http_endpoint, http_resource*>::iterator found_endpoint;
12601260

12611261
size_t len = 0;
12621262
size_t tot_len = 0;
@@ -1368,7 +1368,7 @@ MHD_Result webserver::finalize_answer(MHD_Connection* connection, struct details
13681368
return (MHD_Result) to_ret;
13691369
}
13701370

1371-
MHD_Result webserver::complete_request(MHD_Connection* connection, struct details::modded_request* mr, const char* version, const char* method) {
1371+
MHD_Result webserver::complete_request(MHD_Connection* connection, struct detail::modded_request* mr, const char* version, const char* method) {
13721372
mr->ws = this;
13731373

13741374
mr->dhr->set_path(mr->standardized_url);
@@ -1380,7 +1380,7 @@ MHD_Result webserver::complete_request(MHD_Connection* connection, struct detail
13801380

13811381
MHD_Result webserver::answer_to_connection(void* cls, MHD_Connection* connection, const char* url, const char* method,
13821382
const char* version, const char* upload_data, size_t* upload_data_size, void** con_cls) {
1383-
struct details::modded_request* mr = static_cast<struct details::modded_request*>(*con_cls);
1383+
struct detail::modded_request* mr = static_cast<struct detail::modded_request*>(*con_cls);
13841384

13851385
if (mr->dhr) {
13861386
return static_cast<webserver*>(cls)->requests_answer_second_step(connection, method, version, upload_data, upload_data_size, mr);

0 commit comments

Comments
 (0)