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
8 : //
9 :
10 : #include <boost/http/server/route_handler.hpp>
11 : #include <boost/http/string_body.hpp>
12 : #include <boost/capy/ex/run_sync.hpp>
13 :
14 : namespace boost {
15 : namespace http {
16 :
17 1 : route_params::
18 1 : ~route_params()
19 : {
20 1 : }
21 :
22 : route_params&
23 0 : route_params::
24 : status(
25 : http::status code)
26 : {
27 0 : res.set_start_line(code, res.version());
28 0 : return *this;
29 : }
30 :
31 : route_params&
32 0 : route_params::
33 : set_body(std::string s)
34 : {
35 0 : if(! res.exists(http::field::content_type))
36 : {
37 : // VFALCO TODO detect Content-Type
38 0 : res.set(http::field::content_type,
39 : "text/plain; charset=UTF-8");
40 : }
41 :
42 0 : if(! res.exists(field::content_length))
43 : {
44 0 : res.set_payload_size(s.size());
45 : }
46 :
47 0 : serializer.start(res,
48 0 : http::string_body(std::string(s)));
49 :
50 0 : return *this;
51 : }
52 :
53 : } // http
54 : } // boost
|