ORE Studio 0.0.4
Loading...
Searching...
No Matches
http_info_handler.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*-
2 *
3 * Copyright (C) 2025 Marco Craveiro <marco.craveiro@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify it under
6 * the terms of the GNU General Public License as published by the Free Software
7 * Foundation; either version 3 of the License, or (at your option) any later
8 * version.
9 *
10 * This program is distributed in the hope that it will be useful, but WITHOUT
11 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
12 * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
13 * details.
14 *
15 * You should have received a copy of the GNU General Public License along with
16 * this program; if not, write to the Free Software Foundation, Inc., 51
17 * Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
18 *
19 */
20#ifndef ORES_HTTP_SERVER_MESSAGING_HTTP_INFO_HANDLER_HPP
21#define ORES_HTTP_SERVER_MESSAGING_HTTP_INFO_HANDLER_HPP
22
23#include <string>
24#include "ores.logging/make_logger.hpp"
25#include "ores.nats/domain/message.hpp"
26#include "ores.nats/service/client.hpp"
27#include "ores.service/messaging/handler_helpers.hpp"
28#include "ores.http.api/messaging/http_info_protocol.hpp"
29
30namespace ores::http_server::messaging {
31
32namespace {
33inline auto& http_info_handler_lg() {
34 static auto instance = ores::logging::make_logger(
35 "ores.http.server.messaging.http_info_handler");
36 return instance;
37}
38} // namespace
39
40using ores::service::messaging::reply;
41using ores::service::messaging::decode;
42using namespace ores::logging;
43
51public:
53 std::string base_url)
54 : nats_(nats), base_url_(std::move(base_url)) {}
55
56 void get(ores::nats::message msg) {
57 BOOST_LOG_SEV(http_info_handler_lg(), debug)
58 << "Handling " << msg.subject;
59
61 resp.base_url = base_url_;
62 resp.success = true;
63 reply(nats_, msg, resp);
64
65 BOOST_LOG_SEV(http_info_handler_lg(), debug)
66 << "Replied with base_url: " << base_url_;
67 }
68
69private:
71 std::string base_url_;
72};
73
74} // namespace ores::http_server::messaging
75
76#endif
Implements logging infrastructure for ORE Studio.
Definition boost_severity.hpp:28
Response to get_http_info_request.
Definition http_info_protocol.hpp:46
std::string base_url
The HTTP server's base URL, e.g. "http://localhost:51000".
Definition http_info_protocol.hpp:50
Handles service discovery requests for the HTTP server's base URL.
Definition http_info_handler.hpp:50
A received NATS message.
Definition message.hpp:40
std::string subject
The subject the message was published to.
Definition message.hpp:44
NATS client: connection, pub/sub, request/reply, and JetStream.
Definition client.hpp:73