LCOV - code coverage report
Current view: top level - libs/http_proto/src/server - route_handler.cpp (source / functions) Coverage Total Hit
Test: coverage_filtered.info Lines: 15.4 % 13 2
Test Date: 2026-01-05 11:33:44 Functions: 33.3 % 3 1

            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/route_handler.hpp>
      11              : #include <boost/http_proto/string_body.hpp>
      12              : 
      13              : namespace boost {
      14              : namespace http_proto {
      15              : 
      16            1 : route_params::
      17              : ~route_params()
      18              : {
      19            1 : }
      20              : 
      21              : route_params&
      22            0 : route_params::
      23              : status(
      24              :     http_proto::status code)
      25              : {
      26            0 :     res.set_start_line(code, res.version());
      27            0 :     return *this;
      28              : }
      29              : 
      30              : route_params&
      31            0 : route_params::
      32              : set_body(std::string s)
      33              : {
      34            0 :     if(! res.exists(http_proto::field::content_type))
      35              :     {
      36              :         // VFALCO TODO detect Content-Type
      37            0 :         res.set(http_proto::field::content_type,
      38              :             "text/plain; charset=UTF-8");
      39              :     }
      40              : 
      41            0 :     if(! res.exists(field::content_length))
      42              :     {
      43            0 :         res.set_payload_size(s.size());
      44              :     }
      45              : 
      46            0 :     serializer.start(res,
      47            0 :         http_proto::string_body(std::string(s)));
      48              : 
      49            0 :     return *this;
      50              : }
      51              : 
      52              : #ifdef BOOST_HTTP_PROTO_HAS_CORO
      53              : 
      54              : auto
      55              : route_params::
      56              : spawn(
      57              :     capy::task<route_result> t) ->
      58              :         route_result
      59              : {
      60              :     return this->suspend(
      61              :         [ex = this->ex, t = std::move(t)](resumer resume) mutable
      62              :         {
      63              :             capy::spawn(ex, std::move(t),
      64              :                 [resume](system::result<
      65              :                     route_result, std::exception_ptr> r)
      66              :                 {
      67              :                     if(r.has_error())
      68              :                         resume(r.error());
      69              :                     else
      70              :                         resume(*r);
      71              :                 });
      72              :         });
      73              : }
      74              : 
      75              : #endif
      76              : 
      77              : } // http_proto
      78              : } // boost
        

Generated by: LCOV version 2.1