| 52 | } |
| 53 | |
| 54 | bool http_simple_route_base::exec(const net::http::request_header& hdr, |
| 55 | const_byte_span body, |
| 56 | net::http::router* parent) { |
| 57 | if (method_ && *method_ != hdr.method()) |
| 58 | return false; |
| 59 | // Header might return a relative path when the HTTP request came with a |
| 60 | // request-target in absolute form. See discussion in PR #2079. |
| 61 | // Note: `net::http::make_route` enforces an absolute path. |
| 62 | auto path_compare = [](std::string_view path, std::string_view hdr_path) { |
| 63 | if (hdr_path.empty() || hdr_path.front() != '/') |
| 64 | return path.substr(1) == hdr_path; |
| 65 | else |
| 66 | return path == hdr_path; |
| 67 | }; |
| 68 | if (path_compare(path_, hdr.path())) { |
| 69 | net::http::responder rp{&hdr, body, parent}; |
| 70 | do_apply(rp); |
| 71 | return true; |
| 72 | } |
| 73 | return false; |
| 74 | } |
| 75 | |
| 76 | } // namespace caf::detail |