libs/http/src/server/detail/route_match.hpp
100.0% Lines (1/1)
100.0% Functions (1/1)
-% Branches (0/0)
libs/http/src/server/detail/route_match.hpp
| Line | Hits | Source Code |
|---|---|---|
| 1 | // | |
| 2 | // Copyright (c) 2025 Vinnie Falco (vinnie dot falco at gmail dot com) | |
| 3 | // | |
| 4 | // Distributed under the Boost Software License, Version 1.0. (See accompanying | |
| 5 | // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) | |
| 6 | // | |
| 7 | // Official repository: https://github.com/cppalliance/http | |
| 8 | // | |
| 9 | ||
| 10 | #ifndef BOOST_HTTP_SERVER_DETAIL_ROUTE_MATCH_HPP | |
| 11 | #define BOOST_HTTP_SERVER_DETAIL_ROUTE_MATCH_HPP | |
| 12 | ||
| 13 | #include <boost/http/detail/config.hpp> | |
| 14 | #include <boost/http/server/basic_router.hpp> | |
| 15 | #include "src/server/route_abnf.hpp" | |
| 16 | #include "src/server/detail/stable_string.hpp" | |
| 17 | #include <cstdint> | |
| 18 | #include <string> | |
| 19 | #include <vector> | |
| 20 | ||
| 21 | namespace boost { | |
| 22 | namespace http { | |
| 23 | namespace detail { | |
| 24 | ||
| 25 | // Matches a path against a pattern | |
| 26 | // Members ordered largest-to-smallest for optimal packing | |
| 27 | struct router_base::matcher | |
| 28 | { | |
| 29 | friend class http::flat_router; | |
| 30 | ||
| 31 | matcher(std::string_view pat, bool end_); | |
| 32 | ||
| 33 | // true if match | |
| 34 | bool operator()( | |
| 35 | route_params_base& p, | |
| 36 | match_result& mr) const; | |
| 37 | ||
| 38 | // Returns error from pattern parsing, or empty if valid | |
| 39 | 179 | system::error_code error() const noexcept { return ec_; } |
| 40 | ||
| 41 | private: | |
| 42 | system::error_code ec_; | |
| 43 | std::string allow_header_; | |
| 44 | route_pattern pattern_; | |
| 45 | std::vector<std::string> custom_verbs_; | |
| 46 | ||
| 47 | // 16 bytes (pointer + size) | |
| 48 | stable_string decoded_pat_; | |
| 49 | ||
| 50 | // 8 bytes each | |
| 51 | std::size_t first_entry_ = 0; // flat_router: first entry using this matcher | |
| 52 | std::size_t skip_ = 0; // flat_router: entry index to jump to on failure | |
| 53 | std::uint64_t allowed_methods_ = 0; // flat_router: bitmask of allowed methods | |
| 54 | ||
| 55 | // 4 bytes each | |
| 56 | opt_flags effective_opts_ = 0; // flat_router: computed opts for this scope | |
| 57 | std::uint32_t depth_ = 0; // flat_router: nesting level (0 = root) | |
| 58 | ||
| 59 | // 1 byte each | |
| 60 | bool end_; // false for middleware | |
| 61 | bool slash_; | |
| 62 | }; | |
| 63 | ||
| 64 | } // detail | |
| 65 | } // http | |
| 66 | } // boost | |
| 67 | ||
| 68 | #endif | |
| 69 |