Files
libart-seafire-routing/art/seafire/routing/routing-table.cxx

46 lines
1001 B
C++
Raw Normal View History

2025-10-18 00:44:28 +02:00
#include <art/seafire/routing/routing-table.hxx>
namespace art::seafire::routing
{
routing_table_t::
routing_table_t(std::vector<endpoint_t> endpoints)
: endpoints_{std::move(endpoints)}
{}
std::vector<endpoint_t> const&
routing_table_t::
endpoints() const
{
return endpoints_;
}
std::optional<routing_table_t::find_result_t>
routing_table_t::
2026-01-15 08:46:12 +01:00
find_route(std::string const& host,
std::string const& path,
validator_map_t const& validators) const
2025-10-18 00:44:28 +02:00
{
for (auto const& e : endpoints()) {
host_parameters_t host_params;
2026-01-15 08:46:12 +01:00
if (!match(host, e.host(), validators, '.', host_params)) {
2025-10-18 00:44:28 +02:00
continue;
}
route_parameters_t route_params;
2026-01-15 08:46:12 +01:00
if (match(path, e.path(), validators, '/', route_params)) {
2025-10-18 00:44:28 +02:00
return find_result_t{
std::move(host_params),
std::move(route_params),
e.handler()
};
}
}
return std::nullopt;
}
} // namespace art::seafire::routing