Toolbox snapshot
The Reactive C++ Toolbox
Loading...
Searching...
No Matches
App.hpp
Go to the documentation of this file.
1// The Reactive C++ Toolbox.
2// Copyright (C) 2013-2019 Swirly Cloud Limited
3// Copyright (C) 2022 Reactive Markets Limited
4//
5// Licensed under the Apache License, Version 2.0 (the "License");
6// you may not use this file except in compliance with the License.
7// You may obtain a copy of the License at
8//
9// http://www.apache.org/licenses/LICENSE-2.0
10//
11// Unless required by applicable law or agreed to in writing, software
12// distributed under the License is distributed on an "AS IS" BASIS,
13// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14// See the License for the specific language governing permissions and
15// limitations under the License.
16
17#ifndef TOOLBOX_HTTP_APP_HPP
18#define TOOLBOX_HTTP_APP_HPP
19
20#include <toolbox/http/Conn.hpp>
21
22namespace toolbox {
23inline namespace http {
24
25class OStream;
26class Request;
27
29 public:
32
33 App() noexcept = default;
34 virtual ~App();
35
36 // Copy.
37 constexpr App(const App&) noexcept = default;
38 App& operator=(const App&) noexcept = default;
39
40 // Move.
41 constexpr App(App&&) noexcept = default;
42 App& operator=(App&&) noexcept = default;
43
44 void on_http_connect(CyclTime now, const Endpoint& ep) { do_on_http_connect(now, ep); }
45 void on_http_disconnect(CyclTime now, const Endpoint& ep) noexcept
46 {
47 do_on_http_disconnect(now, ep);
48 }
49 void on_http_error(CyclTime now, const Endpoint& ep, const std::exception& e,
50 OStream& os) noexcept
51 {
52 do_on_http_error(now, ep, e, os);
53 }
54 void on_http_message(CyclTime now, const Endpoint& ep, const Request& req, OStream& os)
55 {
56 do_on_http_message(now, ep, req, os);
57 }
58 void on_http_timeout(CyclTime now, const Endpoint& ep) noexcept { do_on_http_timeout(now, ep); }
59
60 protected:
61 virtual void do_on_http_connect(CyclTime now, const Endpoint& ep) = 0;
62 virtual void do_on_http_disconnect(CyclTime now, const Endpoint& ep) noexcept = 0;
63 virtual void do_on_http_error(CyclTime now, const Endpoint& ep, const std::exception& e,
64 OStream& os) noexcept
65 = 0;
66 virtual void do_on_http_message(CyclTime now, const Endpoint& ep, const Request& req,
67 OStream& os)
68 = 0;
69 virtual void do_on_http_timeout(CyclTime now, const Endpoint& ep) noexcept = 0;
70};
71
72} // namespace http
73} // namespace toolbox
74
75#endif // TOOLBOX_HTTP_APP_HPP
#define TOOLBOX_API
Definition Config.h:39
App() noexcept=default
virtual void do_on_http_timeout(CyclTime now, const Endpoint &ep) noexcept=0
StreamEndpoint Endpoint
Definition App.hpp:31
void on_http_error(CyclTime now, const Endpoint &ep, const std::exception &e, OStream &os) noexcept
Definition App.hpp:49
virtual void do_on_http_error(CyclTime now, const Endpoint &ep, const std::exception &e, OStream &os) noexcept=0
virtual void do_on_http_connect(CyclTime now, const Endpoint &ep)=0
virtual void do_on_http_message(CyclTime now, const Endpoint &ep, const Request &req, OStream &os)=0
void on_http_timeout(CyclTime now, const Endpoint &ep) noexcept
Definition App.hpp:58
virtual void do_on_http_disconnect(CyclTime now, const Endpoint &ep) noexcept=0
void on_http_disconnect(CyclTime now, const Endpoint &ep) noexcept
Definition App.hpp:45
void on_http_message(CyclTime now, const Endpoint &ep, const Request &req, OStream &os)
Definition App.hpp:54
BasicEndpoint< StreamProtocol > StreamEndpoint
Definition Endpoint.hpp:35