src/server/detail/route_match.hpp
100.0% Lines (1/1)
100.0% Functions (1/1)
| Line | TLA | Hits | Source Code |
|---|---|---|---|
| 1 | // | ||
| 2 | // Copyright (c) 2025 Vinnie Falco ([email protected]) | ||
| 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/detail/router_base.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 | |||
| 24 | // Matches a path against a pattern | ||
| 25 | // Members ordered largest-to-smallest for optimal packing | ||
| 26 | struct detail::router_base::matcher | ||
| 27 | { | ||
| 28 | matcher(std::string_view pat, bool end_); | ||
| 29 | |||
| 30 | // true if match | ||
| 31 | bool operator()( | ||
| 32 | route_params& p, | ||
| 33 | match_result& mr) const; | ||
| 34 | |||
| 35 | // Returns error from pattern parsing, or empty if valid | ||
| 36 | 192 | system::error_code error() const noexcept { return ec_; } | |
| 37 | |||
| 38 | private: | ||
| 39 | friend class detail::router_base; | ||
| 40 | friend struct detail::router_base::impl; | ||
| 41 | |||
| 42 | system::error_code ec_; | ||
| 43 | std::string allow_header_; | ||
| 44 | detail::route_pattern pattern_; | ||
| 45 | std::vector<std::string> custom_verbs_; | ||
| 46 | |||
| 47 | // 16 bytes (pointer + size) | ||
| 48 | detail::stable_string decoded_pat_; | ||
| 49 | |||
| 50 | // 8 bytes each | ||
| 51 | std::size_t first_entry_ = 0; | ||
| 52 | std::size_t skip_ = 0; | ||
| 53 | std::uint64_t allowed_methods_ = 0; | ||
| 54 | |||
| 55 | // 4 bytes each | ||
| 56 | opt_flags effective_opts_ = 0; | ||
| 57 | opt_flags own_opts_ = 0; // router's opt_flags (for re-parenting during inline) | ||
| 58 | std::uint32_t depth_ = 0; | ||
| 59 | |||
| 60 | // 1 byte each | ||
| 61 | bool end_; // false for middleware | ||
| 62 | bool slash_; | ||
| 63 | }; | ||
| 64 | |||
| 65 | } // http | ||
| 66 | } // boost | ||
| 67 | |||
| 68 | #endif | ||
| 69 |