LCOV - code coverage report
Current view: top level - src/json - json_body.cpp (source / functions) Coverage Total Hit
Test: coverage_remapped.info Lines: 0.0 % 6 0
Test Date: 2026-02-09 01:37:05 Functions: 0.0 % 2 0

            Line data    Source code
       1              : //
       2              : // Copyright (c) 2025 Vinnie Falco (vinnie.falco@gmail.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/json/json_body.hpp>
      11              : #include <boost/http/json/json_sink.hpp>
      12              : #include <boost/http/field.hpp>
      13              : #include <boost/http/method.hpp>
      14              : #include <boost/capy/io/push_to.hpp>
      15              : #include <boost/json/value.hpp>
      16              : 
      17              : namespace boost {
      18              : namespace http {
      19              : 
      20            0 : json_body::
      21            0 : json_body(json_body_options options) noexcept
      22            0 :     : options_(std::move(options))
      23              : {
      24            0 : }
      25              : 
      26              : route_task
      27            0 : json_body::
      28              : operator()(route_params& p) const
      29              : {
      30              :     if( ! p.is_method(method::post) ||
      31              :         ! p.req.value_or(
      32              :             field::content_type, "")
      33              :                 .starts_with("application/json"))
      34              :         co_return route_next;
      35              : 
      36              :     json_sink sink(
      37              :         options_.storage, options_.parse_opts);
      38              :     auto [ec, n] = co_await capy::push_to(
      39              :         p.req_body, sink);
      40              :     if(ec)
      41              :         co_return route_error(ec);
      42              : 
      43              :     p.route_data.emplace<json::value>(
      44              :         sink.release());
      45              : 
      46              :     co_return route_next;
      47            0 : }
      48              : 
      49              : } // namespace http
      50              : } // namespace boost
        

Generated by: LCOV version 2.3