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
17template <typename T>
18concept SomeResolver = requires(T t) {
19 std::is_default_constructible_v<T>;
20 { t.resolve(std::string_view{}, std::string_view{}) } -> std::same_as<std::vector<std::string>>;
21 { t.resolve(std::string_view{}) } -> std::same_as<std::vector<std::string>>;
22};
23
27class Resolver {
28 boost::asio::io_context ioContext_;
29 boost::asio::ip::tcp::resolver resolver_{ioContext_};
30
31public:
40 std::vector<std::string>
41 resolve(std::string_view hostname);
42
52 std::vector<std::string>
53 resolve(std::string_view hostname, std::string_view service);
54
55private:
56 std::vector<boost::asio::ip::tcp::endpoint>
57 doResolve(std::string_view hostname, std::string_view service);
58};
59
60} // namespace web
Simple hostnames to IP addresses resolver.
Definition Resolver.hpp:27
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:18
This namespace implements the web server and related components.
Definition Types.hpp:24