GCC Code Coverage Report


Directory: ./
File: libs/beast2/src/server/http_server.cpp
Date: 2026-01-04 15:38:14
Exec Total Coverage
Lines: 0 24 0.0%
Functions: 0 6 0.0%
Branches: 0 4 0.0%

Line Branch Exec Source
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/beast2
8 //
9
10 #include <boost/beast2/server/http_server.hpp>
11 #include <boost/beast2/server/http_stream.hpp>
12 #include <boost/beast2/server/plain_worker.hpp>
13 #include <boost/beast2/asio_io_context.hpp>
14 #include <boost/capy/application.hpp>
15
16 namespace boost {
17 namespace beast2 {
18
19 namespace {
20
21 template<class Stream>
22 class http_server_impl
23 : public http_server<Stream>
24 {
25 public:
26 ✗ http_server_impl(
27 capy::application& app,
28 std::size_t num_workers)
29 ✗ : ioc_(install_single_threaded_asio_io_context(app))
30 ✗ , w_(app,
31 ✗ ioc_.get_executor(), 1, num_workers,
32 ✗ ioc_.get_executor(), this->wwwroot)
33 {
34 ✗ }
35
36 ✗ void add_port(
37 char const* addr,
38 unsigned short port)
39 {
40 ✗ w_.emplace(
41 http::acceptor_config{ false, false },
42 ✗ asio::ip::tcp::endpoint(
43 asio::ip::make_address(addr),
44 port),
45 ✗ true);
46 ✗ }
47
48 ✗ void start()
49 {
50 ✗ w_.start();
51 ✗ }
52
53 ✗ void stop()
54 {
55 ✗ w_.stop();
56 ✗ }
57
58 ✗ void attach() override
59 {
60 ✗ ioc_.attach();
61 ✗ }
62
63 private:
64 using workers_type = workers< plain_worker<
65 asio::io_context::executor_type, asio::ip::tcp> >;
66
67 asio_io_context& ioc_;
68 workers_type w_;
69 };
70
71 } // (anon)
72
73 //------------------------------------------------
74
75 auto
76 ✗ install_plain_http_server(
77 capy::application& app,
78 char const* addr,
79 unsigned short port,
80 std::size_t num_workers) ->
81 http_server<asio::basic_stream_socket<
82 asio::ip::tcp,
83 asio::io_context::executor_type>>&
84 {
85 using stream_type = asio::basic_stream_socket<
86 asio::ip::tcp, asio::io_context::executor_type>;
87 ✗ auto& srv = app.emplace<http_server_impl<stream_type>>(
88 app, num_workers);
89 ✗ srv.add_port(addr, port);
90 ✗ return srv;
91 }
92
93 } // beast2
94 } // boost
95
96