@@ -1821,7 +1821,9 @@ struct sqlite_database {
18211821
18221822#ifndef LITHIUM_SINGLE_HEADER_GUARD_LI_HTTP_CLIENT_HTTP_CLIENT_HH
18231823#define LITHIUM_SINGLE_HEADER_GUARD_LI_HTTP_CLIENT_HTTP_CLIENT_HH
1824+ #ifndef CURL_STATICLIB
18241825#define CURL_STATICLIB
1826+ #endif // CURL_STATICLIB
18251827#pragma comment(lib, "crypt32")
18261828#pragma comment(lib, "ws2_32.lib")
18271829#pragma comment(lib, "Wldap32.lib")
@@ -5490,6 +5492,7 @@ template <typename I> struct sql_database {
54905492};
54915493
54925494}
5495+
54935496#endif // LITHIUM_SINGLE_HEADER_GUARD_LI_SQL_SQL_DATABASE_HH
54945497
54955498
@@ -6834,7 +6837,7 @@ template <typename Req, typename Resp> struct api {
68346837
68356838 typedef api<Req, Resp> self;
68366839
6837- api (): is_global_handler(false ), global_handler_(nullptr ) { }
6840+ api () : is_global_handler(false ), global_handler_(nullptr ) {}
68386841
68396842 using H = std::function<void (Req&, Resp&)>;
68406843 struct VH {
@@ -6875,7 +6878,9 @@ template <typename Req, typename Resp> struct api {
68756878
68766879 void add_subapi (std::string prefix, const self& subapi) {
68776880 subapi.routes_map_ .for_all_routes ([this , prefix](auto r, VH h) {
6878- if (!r.empty () && r.back () == ' /' )
6881+ if (r.empty () || r == " /" )
6882+ h.url_spec = prefix;
6883+ else if (r.back () == ' /' )
68796884 h.url_spec = prefix + r;
68806885 else
68816886 h.url_spec = prefix + ' /' + r;
@@ -6893,13 +6898,11 @@ template <typename Req, typename Resp> struct api {
68936898 std::cout << std::endl;
68946899 }
68956900 auto call (std::string_view method, std::string_view route, Req& request, Resp& response) const {
6896- if (is_global_handler)
6897- {
6898- global_handler_ (request, response);
6899- return ;
6901+ if (is_global_handler) {
6902+ global_handler_ (request, response);
6903+ return ;
69006904 }
6901- if (route == last_called_route_)
6902- {
6905+ if (route == last_called_route_) {
69036906 if (last_handler_.verb == ANY or parse_verb (method) == last_handler_.verb ) {
69046907 request.url_spec = last_handler_.url_spec ;
69056908 last_handler_.handler (request, response);
@@ -6910,7 +6913,8 @@ template <typename Req, typename Resp> struct api {
69106913
69116914 // skip the last / of the url and trim spaces.
69126915 std::string_view route2 (route);
6913- while (route2.size () > 1 and (route2[route2.size () - 1 ] == ' /' || route2[route2.size () - 1 ] == ' ' ))
6916+ while (route2.size () > 1 and
6917+ (route2[route2.size () - 1 ] == ' /' || route2[route2.size () - 1 ] == ' ' ))
69146918 route2 = route2.substr (0 , route2.size () - 1 );
69156919
69166920 auto it = routes_map_.find (route2);
0 commit comments