Line data 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_proto
8 : //
9 :
10 : #include <boost/http_proto/server/router_types.hpp>
11 : #include <boost/url/grammar/ci_string.hpp>
12 : #include <boost/assert.hpp>
13 : #include <cstring>
14 :
15 : namespace boost {
16 : namespace http_proto {
17 :
18 : namespace detail {
19 :
20 : const char*
21 6 : route_cat_type::
22 : name() const noexcept
23 : {
24 6 : return "boost.http.route";
25 : }
26 :
27 : std::string
28 300 : route_cat_type::
29 : message(int code) const
30 : {
31 600 : return message(code, nullptr, 0);
32 : }
33 :
34 : char const*
35 300 : route_cat_type::
36 : message(
37 : int code,
38 : char*,
39 : std::size_t) const noexcept
40 : {
41 300 : switch(static_cast<route>(code))
42 : {
43 3 : case route::close: return "close";
44 3 : case route::complete: return "complete";
45 5 : case route::suspend: return "suspend";
46 99 : case route::next: return "next";
47 1 : case route::next_route: return "next_route";
48 189 : case route::send: return "send";
49 0 : default:
50 0 : return "?";
51 : }
52 : }
53 :
54 : // msvc 14.0 has a bug that warns about inability
55 : // to use constexpr construction here, even though
56 : // there's no constexpr construction
57 : #if defined(_MSC_VER) && _MSC_VER <= 1900
58 : # pragma warning( push )
59 : # pragma warning( disable : 4592 )
60 : #endif
61 :
62 : #if defined(__cpp_constinit) && __cpp_constinit >= 201907L
63 : constinit route_cat_type route_cat;
64 : #else
65 : route_cat_type route_cat;
66 : #endif
67 :
68 : #if defined(_MSC_VER) && _MSC_VER <= 1900
69 : # pragma warning( pop )
70 : #endif
71 :
72 : } // detail
73 :
74 : resumer
75 0 : suspender::
76 : owner::
77 : do_suspend()
78 : {
79 0 : detail::throw_logic_error();
80 : }
81 :
82 : bool
83 3 : route_params_base::
84 : is_method(
85 : core::string_view s) const noexcept
86 : {
87 3 : auto m = http_proto::string_to_method(s);
88 3 : if(m != http_proto::method::unknown)
89 2 : return verb_ == m;
90 1 : return s == verb_str_;
91 : }
92 :
93 : } // http_proto
94 : } // boost
|