Clio  develop
The XRP Ledger API server.
Loading...
Searching...
No Matches
Resolver.hpp
1#pragma once
2
3#include <boost/asio.hpp>
4#include <boost/asio/io_context.hpp>
5#include <boost/asio/ip/tcp.hpp>
6
7#include <concepts>
8#include <string>
9#include <string_view>
10#include <vector>
11
12namespace web {
13
19template <typename T>
20concept SomeResolver = requires(T t) {
21 std::is_default_constructible_v<T>;
22 { t.resolve(std::string_view{}, std::string_view{}) } -> std::same_as<std::vector<std::string>>;
23 { t.resolve(std::string_view{}) } -> std::same_as<std::vector<std::string>>;
24};
25
29class Resolver {
30 boost::asio::io_context ioContext_;
31 boost::asio::ip::tcp::resolver resolver_{ioContext_};
32
33public:
42 std::vector<std::string>
43 resolve(std::string_view hostname);
44
54 std::vector<std::string>
55 resolve(std::string_view hostname, std::string_view service);
56
57private:
58 std::vector<boost::asio::ip::tcp::endpoint>
59 doResolve(std::string_view hostname, std::string_view service);
60};
61
62} // namespace web
Simple hostnames to IP addresses resolver.
Definition Resolver.hpp:29
std::vector< std::string > resolve(std::string_view hostname)
Resolve hostname to IP addresses.
Definition Resolver.cpp:65
The requirements of a resolver.
Definition Resolver.hpp:20
This namespace implements the web server and related components.
Definition Types.hpp:23