module; #include #include #include export module routemon:http.ext.json; import std; import :http.core.common; import :util; namespace routemon::http::ext::json { namespace { namespace json = boost::json; } // namespace struct body { using value_type = json::value; class reader { json::stream_parser p_; util::not_null v_; public: template explicit reader(bhttp::header&, value_type& v) : v_{util::not_null{&v}} { } auto init(boost::optional /* n */, beast::error_code& ec) noexcept -> void; auto put(beast::concepts::const_buffer_sequence auto b, beast::error_code& ec) noexcept -> std::size_t { ec = {}; auto wrote = 0uz; for (auto const buf : beast::buffers_range(b)) { p_.write(static_cast(buf.data()), buf.size(), ec); wrote += buf.size(); if (ec) break; } return wrote; } auto finish(beast::error_code& ec) noexcept -> void; }; }; static_assert(bhttp::concepts::body); static_assert(bhttp::concepts::body_reader); } // namespace routemon::http::ext::json