| 1 |
|
|
1 |
|
|
| 2 |
|
// Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
|
2 |
|
// Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.com)
|
| 3 |
|
|
3 |
|
|
| 4 |
|
// Distributed under the Boost Software License, Version 1.0. (See accompanying
|
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)
|
5 |
|
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
|
| 6 |
|
|
6 |
|
|
| 7 |
|
// Official repository: https://github.com/cppalliance/http
|
7 |
|
// Official repository: https://github.com/cppalliance/http
|
| 8 |
|
|
8 |
|
|
| 9 |
|
|
9 |
|
|
| 10 |
|
#include <boost/http/json/json_body.hpp>
|
10 |
|
#include <boost/http/json/json_body.hpp>
|
| 11 |
|
#include <boost/http/json/json_sink.hpp>
|
11 |
|
#include <boost/http/json/json_sink.hpp>
|
| 12 |
|
#include <boost/http/field.hpp>
|
12 |
|
#include <boost/http/field.hpp>
|
| 13 |
|
#include <boost/http/method.hpp>
|
13 |
|
#include <boost/http/method.hpp>
|
| 14 |
|
#include <boost/capy/io/push_to.hpp>
|
14 |
|
#include <boost/capy/io/push_to.hpp>
|
| 15 |
|
#include <boost/json/value.hpp>
|
15 |
|
#include <boost/json/value.hpp>
|
| 16 |
|
|
16 |
|
|
| 17 |
|
|
17 |
|
|
| 18 |
|
|
18 |
|
|
| 19 |
|
|
19 |
|
|
| 20 |
|
|
20 |
|
|
| 21 |
|
json_body(json_body_options options) noexcept
|
21 |
|
json_body(json_body_options options) noexcept
|
| 22 |
|
: options_(std::move(options))
|
22 |
|
: options_(std::move(options))
|
| 23 |
|
|
23 |
|
|
| 24 |
|
|
24 |
|
|
| 25 |
|
|
25 |
|
|
| 26 |
|
|
26 |
|
|
| 27 |
|
|
27 |
|
|
| 28 |
|
operator()(route_params& p) const
|
28 |
|
operator()(route_params& p) const
|
| 29 |
|
|
29 |
|
|
| 30 |
|
if( ! p.is_method(method::post) ||
|
30 |
|
if( ! p.is_method(method::post) ||
|
| 31 |
|
|
31 |
|
|
| 32 |
|
|
32 |
|
|
| 33 |
|
.starts_with("application/json"))
|
33 |
|
.starts_with("application/json"))
|
| 34 |
|
|
34 |
|
|
| 35 |
|
|
35 |
|
|
| 36 |
|
|
36 |
|
|
| 37 |
|
options_.storage, options_.parse_opts);
|
37 |
|
options_.storage, options_.parse_opts);
|
| 38 |
|
auto [ec, n] = co_await capy::push_to(
|
38 |
|
auto [ec, n] = co_await capy::push_to(
|
| 39 |
|
|
39 |
|
|
| 40 |
|
|
40 |
|
|
| 41 |
|
co_return route_error(ec);
|
41 |
|
co_return route_error(ec);
|
| 42 |
|
|
42 |
|
|
| 43 |
|
p.route_data.emplace<json::value>(
|
43 |
|
p.route_data.emplace<json::value>(
|
| 44 |
|
|
44 |
|
|
| 45 |
|
|
45 |
|
|
| 46 |
|
|
46 |
|
|
| 47 |
|
|
47 |
|
|
| 48 |
|
|
48 |
|
|
| 49 |
|
|
49 |
|
|
| 50 |
|
|
50 |
|
|