Hello Seafire

This commit is contained in:
R.Y.A.N 2025-03-07 02:25:54 +01:00
commit 43fae1f322
Signed by: R.Y.A.N
GPG Key ID: 3BD93EABD1407B82
37 changed files with 1277 additions and 0 deletions

17
.editorconfig Normal file
View File

@ -0,0 +1,17 @@
root = true
[*]
indent_style = space
indent_size = 2
end_of_line = lf
charset = utf-8
trim_trailing_whitespace = true
insert_final_newline = true
[*.md]
indent_size = 4
max_line_length = off
trim_trailing_whitespace = false
[*.yaml]
indent_size = 2

1
.gitattributes vendored Normal file
View File

@ -0,0 +1 @@
* text=auto

32
.gitignore vendored Normal file
View File

@ -0,0 +1,32 @@
.bdep/
Doxyfile
# Local default options files.
#
.build2/local/
# Compiler/linker output.
#
*.d
*.t
*.i
*.i.*
*.ii
*.ii.*
*.o
*.obj
*.gcm
*.pcm
*.ifc
*.so
*.dylib
*.dll
*.a
*.lib
*.exp
*.pdb
*.ilk
*.exe
*.exe.dlls/
*.exe.manifest
*.pc

32
LICENSE.md Normal file
View File

@ -0,0 +1,32 @@
Copyright © 2025 Per Ryan Edin. All rights reserved.
Redistribution and use in source and binary forms, with or without modification,
are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright notice, this
list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright notice,
this list of conditions and the following disclaimer in the documentation and/or
other materials provided with the distribution.
3. All advertising materials mentioning features or use of this software must
display the following acknowledgement:
> This product includes Seafire, an HTTP/1.1 implementation
> for C++ applications. Developed by Ryan, http://helloryan.se.
4. Neither the name(s) of the copyright holder(s) nor the names of its
contributors may be used to endorse or promote products derived from this
software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY COPYRIGHT HOLDER "AS IS" AND ANY EXPRESS OR IMPLIED
WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT
SHALL COPYRIGHT HOLDER BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY
OF SUCH DAMAGE.

10
README.md Normal file
View File

@ -0,0 +1,10 @@
# Seafire
## Contact
Please report bugs and issues by sending an e-mail to: ryan@helloryan.se.
## Contributing
Please send an e-mail to ryan@helloryan.se to request an account and repository
write access.

4
build/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/config.build
/root/
/bootstrap/
build/

7
build/bootstrap.build Normal file
View File

@ -0,0 +1,7 @@
project = seafire-routing
using version
using config
using test
using install
using dist

6
build/export.build Normal file
View File

@ -0,0 +1,6 @@
$out_root/
{
include seafire/routing/
}
export $out_root/seafire/routing/$import.target

16
build/root.build Normal file
View File

@ -0,0 +1,16 @@
# Uncomment to suppress warnings coming from external libraries.
#
#cxx.internal.scope = current
cxx.std = latest
using cxx
hxx{*}: extension = hxx
ixx{*}: extension = ixx
txx{*}: extension = txx
cxx{*}: extension = cxx
# The test target for cross-testing (running tests under Wine, etc).
#
test.target = $cxx.target

5
buildfile Normal file
View File

@ -0,0 +1,5 @@
./: {seafire/ tests/} doc{README.md} legal{LICENSE.md} manifest
# Don't install tests.
#
tests/: install = false

15
manifest Normal file
View File

@ -0,0 +1,15 @@
: 1
name: seafire-routing
version: 0.1.0-a.0.z
language: c++
summary: Seafire Routing C++ library
license: BSD-4-Clause
description-file: README.md
url: https://helloryan.se/
email: ryan@helloryan.se
depends: * build2 >= 0.17.0
depends: * bpkg >= 0.17.0
depends: libcode-uri ^0.1.0-
depends: seafire-common ^0.1.0-
depends: seafire-protocol ^0.1.0-
depends: seafire-server ^0.1.0-

23
repositories.manifest Normal file
View File

@ -0,0 +1,23 @@
: 1
summary: Seafire-Representation project repository
:
role: prerequisite
location: https://pkg.cppget.org/1/beta
trust: 70:64:FE:E4:E0:F3:60:F1:B4:51:E1:FA:12:5C:E0:B3:DB:DF:96:33:39:B9:2E:E5:C2:68:63:4C:A6:47:39:43
:
role: prerequisite
location: https://code.helloryan.se/code/libcode-uri.git##HEAD
:
role: prerequisite
location: https://code.helloryan.se/creatures/Seafire-Common.git##HEAD
:
role: prerequisite
location: https://code.helloryan.se/creatures/Seafire-Protocol.git##HEAD
:
role: prerequisite
location: https://code.helloryan.se/creatures/Seafire-Server.git##HEAD

9
seafire/routing/.gitignore vendored Normal file
View File

@ -0,0 +1,9 @@
# Generated version header.
#
version.hxx
# Unit test executables and Testscript output directories
# (can be symlinks).
#
*.test
test-*.test

67
seafire/routing/buildfile Normal file
View File

@ -0,0 +1,67 @@
intf_libs = # Interface dependencies.
impl_libs = # Implementation dependencies.
import impl_libs =+ libcode-uri%lib{code-uri}
import intf_libs =+ seafire-common%lib{seafire-common}
import intf_libs =+ seafire-protocol%lib{seafire-protocol}
import intf_libs =+ seafire-server%lib{seafire-server}
./: lib{seafire-routing}: libul{seafire-routing}
libul{seafire-routing}: {hxx ixx txx cxx}{** -**.test... -version} \
{hxx }{ version}
libul{seafire-routing}: $impl_libs $intf_libs
# Unit tests.
#
exe{*.test}:
{
test = true
install = false
}
for t: cxx{**.test...}
{
d = $directory($t)
n = $name($t)...
./: $d/exe{$n}: $t $d/{hxx ixx txx}{+$n} $d/testscript{+$n}
$d/exe{$n}: libul{seafire-routing}: bin.whole = false
}
hxx{version}: in{version} $src_root/manifest
{
dist = true
clean = ($src_root != $out_root)
}
# Build options.
#
cxx.poptions =+ "-I$out_root" "-I$src_root"
# Export options.
#
lib{seafire-routing}:
{
cxx.export.poptions = "-I$out_root" "-I$src_root"
cxx.export.libs = $intf_libs
}
# For pre-releases use the complete version to make sure they cannot
# be used in place of another pre-release or the final version. See
# the version module for details on the version.* variable values.
#
if $version.pre_release
lib{seafire-routing}: bin.lib.version = "-$version.project_id"
else
lib{seafire-routing}: bin.lib.version = "-$version.major.$version.minor"
# Install into the seafire/routing/ subdirectory of, say, /usr/include/
# recreating subdirectories.
#
{hxx ixx txx}{*}:
{
install = include/seafire/routing/
install.subdirs = true
}

View File

@ -0,0 +1,15 @@
#include <seafire/routing/diagnostics.hxx>
namespace seafire::routing
{
/// Returns a reference to the routing diagnostic category.
///
common::diagnostics_t::category_t const&
routing_category()
{
static common::diagnostics_t::category_t category{"router"};
return category;
}
} // namespace seafire::routing

View File

@ -0,0 +1,14 @@
#ifndef seafire__routing__diagnostics_hxx_
#define seafire__routing__diagnostics_hxx_
#include <seafire/common/diagnostics.hxx>
namespace seafire::routing
{
common::diagnostics_t::category_t const&
routing_category();
} // namespace seafire::routing
#endif

View File

@ -0,0 +1,37 @@
#include <seafire/routing/endpoint.hxx>
namespace seafire::routing
{
endpoint_t::
endpoint_t(std::string pattern, server::request_handler_t handler)
: pattern_{std::move(pattern)}, handler_{std::move(handler)}
{}
std::string const&
endpoint_t::
pattern() const
{
return pattern_;
}
server::request_handler_t const&
endpoint_t::
handler() const
{
return handler_;
}
std::ostream&
to_stream(std::ostream& o, endpoint_t const& ep)
{
return o << ep.pattern();
}
std::ostream&
operator<<(std::ostream& o, endpoint_t const& ep)
{
return to_stream(o, ep);
}
} // namespace seafire::routing

View File

@ -0,0 +1,37 @@
#ifndef seafire__routing__endpoint_hxx_
#define seafire__routing__endpoint_hxx_
#include <seafire/server/request-handler.hxx>
#include <ostream>
#include <string>
namespace seafire::routing
{
class endpoint_t
{
public:
endpoint_t(std::string, server::request_handler_t);
std::string const&
pattern() const;
server::request_handler_t const&
handler() const;
private:
std::string pattern_;
server::request_handler_t handler_;
};
std::ostream&
to_stream(std::ostream&, endpoint_t const&);
std::ostream&
operator<<(std::ostream&, endpoint_t const&);
} // namespace seafire::routing
#endif

View File

@ -0,0 +1,50 @@
#include <seafire/routing/flatten-route.hxx>
namespace seafire::routing
{
void
flatten_route(std::vector<endpoint_t>& endpoints,
std::vector<server::middleware_t> middlewares,
route_t const& route,
std::string const& root)
{
auto const path = root + route.path();
// append any middlewares if we have any.
//
for (auto const& m : route.middleware()) {
middlewares.emplace_back(m);
}
// generate an endpoint for this route if we have a handler.
//
if (auto const& h = route.handler()) {
endpoints.emplace_back(path, server::make_middleware(middlewares, *h));
}
// flatten any child routes.
//
for (auto const& child_route : route.children()) {
flatten_route(endpoints,
middlewares,
child_route,
route.path().empty() ? path : path + '/');
}
}
void
flatten_route(std::vector<endpoint_t>& endpoints, route_t const& r)
{
flatten_route(endpoints, {}, r, "/");
}
std::vector<endpoint_t>
flatten_route(route_t const& r)
{
std::vector<endpoint_t> endpoints;
flatten_route(endpoints, r);
return endpoints;
}
} // namespace seafire::routing

View File

@ -0,0 +1,28 @@
#ifndef seafire__routing__flatten_route_hxx_
#define seafire__routing__flatten_route_hxx_
#include <seafire/routing/endpoint.hxx>
#include <seafire/routing/route.hxx>
#include <seafire/server/middleware.hxx>
#include <vector>
namespace seafire::routing
{
void
flatten_route(std::vector<endpoint_t>& endpoints,
std::vector<server::middleware_t>,
route_t const& r,
std::string const& root);
void
flatten_route(std::vector<endpoint_t>&, route_t const&);
std::vector<endpoint_t>
flatten_route(route_t const&);
} // namespace seafire::routing
#endif

View File

@ -0,0 +1,116 @@
#include <seafire/routing/match-path.hxx>
#include <sstream>
#include <vector>
#include <iostream>
namespace seafire::routing
{
bool
match_path(std::string const& pattern,
std::string const& subject,
route_parameters_t& params)
{
route_parameters_t tmp_params;
// p/pend = pattern iterators.
//
auto p = pattern.begin();
auto const pend = pattern.end();
// s/send = subject iterators.
//
auto s = subject.begin();
auto const send = subject.end();
auto match_param = [&]()
{
// k/kend = local pattern iterators.
//
auto const k = p;
while (p != pend && '}' != *p) {
++p;
}
auto const kend = p;
++p;
if (k == kend) {
throw std::invalid_argument{"empty parameter name"};
}
// a greedy parameter will eat the rest of the subject.
//
bool const greedy{'*' == *k && 1 == std::distance(k, kend)};
// v/vend = local subject iterators.
//
auto const v = s;
while (s != send && (greedy || '/' != *s)) {
++s;
}
auto const vend = s;
tmp_params.map().emplace(std::string{k, kend}, std::string{v, vend});
};
while (p != pend) {
if (*p == '{') {
++p;
match_param();
continue;
}
if (s == send) {
break;
}
if (*p != *s) {
return false;
}
++p;
++s;
}
if (p != pend || s != send) {
return false;
}
params = std::move(tmp_params);
return true;
}
std::string
render_path(std::string const& pattern,
route_parameters_t const& params)
{
std::stringstream str;
auto p = pattern.begin();
auto pend = pattern.end();
while (p != pend) {
if (*p == '{') {
++p;
auto const k = p;
while (p != pend && '}' != *p) {
++p;
}
auto const kend = p;
str << params.get(std::string{k, kend}).value_or("<unknown>");
}
else {
str << *p;
}
++p;
}
return str.str();
}
} // namespace seafire::routing

View File

@ -0,0 +1,24 @@
#ifndef seafire__routing__match_path_hxx_
#define seafire__routing__match_path_hxx_
#include <seafire/routing/route-parameters.hxx>
#include <code/uri/uri.hxx>
#include <string>
namespace seafire::routing
{
bool
match_path(std::string const&,
std::string const&,
route_parameters_t&);
std::string
render_path(std::string const&,
route_parameters_t&);
} // namespace seafire::routing
#endif

View File

@ -0,0 +1,68 @@
#ifndef seafire__routing__route_parameter_hxx_
#define seafire__routing__route_parameter_hxx_
#include <seafire/server/parameters.hxx>
#include <seafire/server/request.hxx>
#include <seafire/routing/route-parameters.hxx>
#include <optional>
namespace seafire::routing
{
template<
server::parameter_name_t Name,
typename ParameterType = server::string_parameter_t
>
class route_parameter_t
{
public:
using parameter_type = ParameterType;
using value_type = typename parameter_type::value_type;
static
std::string const&
name()
{
static std::string const name{Name};
return name;
}
route_parameter_t(std::optional<value_type> value)
: _value{std::move(value)}
{}
std::optional<value_type> const&
value() const
{
return _value;
}
operator std::optional<value_type> const&() const
{
return value();
}
std::optional<value_type> const*
operator->() const
{
return &value();
}
static
route_parameter_t<Name, ParameterType>
fetch(server::request_t& req)
{
auto v = req.extensions().use<route_parameters_t>().get(name());
return parameter_type::try_parse(v);
}
private:
std::optional<value_type> _value;
};
} // namespace seafire::routing
#endif

View File

@ -0,0 +1,30 @@
#include <seafire/routing/route-parameters.hxx>
namespace seafire::routing
{
std::map<std::string, std::string>&
route_parameters_t::
map()
{
return kv_;
}
std::map<std::string, std::string> const&
route_parameters_t::
map() const
{
return kv_;
}
std::optional<std::string>
route_parameters_t::
get(std::string const& key) const
{
if (auto it = map().find(key); it != map().end())
return it->second;
return std::nullopt;
}
} // namespace seafire::routing

View File

@ -0,0 +1,30 @@
#ifndef seafire__routing__route_parameters_hxx_
#define seafire__routing__route_parameters_hxx_
#include <map>
#include <optional>
#include <string>
namespace seafire::routing
{
class route_parameters_t
{
public:
std::map<std::string, std::string>&
map();
std::map<std::string, std::string> const&
map() const;
std::optional<std::string>
get(std::string const& key) const;
private:
std::map<std::string, std::string> kv_;
};
} // namespace seafire::routing
#endif

134
seafire/routing/route.cxx Normal file
View File

@ -0,0 +1,134 @@
#include <seafire/routing/route.hxx>
#include <stdexcept>
namespace seafire::routing
{
static
void
ensure_valid_path(std::string const& path)
{
if (!path.empty()) {
if (path.front() == '/') {
throw std::invalid_argument{"route path must not start with '/'"};
}
if (path.back() == '/') {
throw std::invalid_argument{"route path must not end with '/'"};
}
}
}
route_t::
route_t() = default;
route_t::
route_t(std::string path)
: path_{std::move(path)}
{
ensure_valid_path(path_);
}
route_t::
route_t(std::string path, server::request_handler_t handler)
: path_{std::move(path)}, handler_{std::move(handler)}
{
ensure_valid_path(path_);
}
std::string const&
route_t::
path() const
{
return path_;
}
std::vector<server::middleware_t> const&
route_t::
middleware() const
{
return middleware_;
}
std::optional<server::request_handler_t> const&
route_t::
handler() const
{
return handler_;
}
std::list<route_t> const&
route_t::
children() const
{
return children_;
}
void
route_t::
use(server::middleware_t m)
{
middleware_.emplace_back(std::move(m));
}
route_t&
route_t::
add_route()
{
children_.emplace_back();
return children_.back();
}
route_t&
route_t::
add_route(route_t r)
{
children_.emplace_back(std::move(r));
return children_.back();
}
route_t&
route_t::
add_route(std::string path)
{
return add_route(route_t{std::move(path)});
}
route_t&
route_t::
add_route(std::string path, server::request_handler_t handler)
{
return add_route(route_t{std::move(path), std::move(handler)});
}
std::ostream&
to_stream(std::ostream& o, route_t const& r, std::size_t indent)
{
o << std::string(indent, ' ');
o << " -> '" << (r.path().empty() ? "<empty>" : r.path()) << '\'';
if (!r.middleware().empty()) {
o << " (with middleware)";
}
if (!r.handler()) {
o << " (null handler)";
}
o << '\n';
for (auto const& child : r.children()) {
to_stream(o, child, indent + 2);
}
return o;
}
std::ostream&
operator<<(std::ostream& o, route_t const& route)
{
return to_stream(o, route, 0);
}
} // namespace seafire::routing

74
seafire/routing/route.hxx Normal file
View File

@ -0,0 +1,74 @@
#ifndef seafire__routing__route_hxx_
#define seafire__routing__route_hxx_
#include <seafire/routing/endpoint.hxx>
#include <seafire/server/middleware.hxx>
#include <seafire/server/request-handler.hxx>
#include <iostream>
#include <list>
#include <optional>
#include <vector>
namespace seafire::routing
{
class route_t
{
public:
route_t();
explicit
route_t(std::string);
route_t(std::string, server::request_handler_t);
std::string const&
path() const;
std::vector<server::middleware_t> const&
middleware() const;
std::optional<server::request_handler_t> const&
handler() const;
std::list<route_t> const&
children() const;
void
use(server::middleware_t);
route_t&
add_route();
route_t&
add_route(route_t);
route_t&
add_route(std::string);
route_t&
add_route(std::string, server::request_handler_t);
private:
std::string path_;
std::vector<server::middleware_t> middleware_;
std::optional<server::request_handler_t> handler_;
// must be std::list to prevent invalidation of references to
// individual routes.
//
std::list<route_t> children_;
};
std::ostream&
to_stream(std::ostream&, route_t const&, std::size_t);
std::ostream&
operator<<(std::ostream&, route_t const&);
} // namespace seafire::routing
#endif

102
seafire/routing/router.cxx Normal file
View File

@ -0,0 +1,102 @@
#include <seafire/routing/router.hxx>
#include <seafire/routing/diagnostics.hxx>
namespace seafire::routing
{
static
std::string
normalize_path(std::string const& path)
{
std::stringstream ipath{path};
std::vector<std::string> segments;
for (std::string segment; std::getline(ipath, segment, '/');) {
if (segment.empty()) {
continue;
}
if (segment == ".") {
continue;
}
if (segment == "..") {
if (!segments.empty()) {
segments.pop_back();
}
continue;
}
segments.push_back(segment);
}
std::string normalized;
for (auto const& j : segments) {
normalized += '/';
normalized += j;
}
return normalized.empty() ? "/" : normalized;
}
router_t::
router_t(common::diagnostics_t& diagnostics, routing_table_t table)
: diagnostics_{diagnostics}, rt_{std::move(table)}
{}
routing_table_t const&
router_t::
routing_table() const
{
return rt_;
}
void
router_t::
on_request(server::request_t& req, server::response_t& res) const
{
trace() << "on_request(...)";
auto path = normalize_path(req.get_message().target_uri().path_str());
trace() << "locating endpoint for [" << path << "]";
auto result = routing_table().find_route(path);
if (!result) {
trace() << "endpoint for [" << path << "] not found";
res.send(server::common_error_t::not_found);
return;
}
auto trace_endpoint = [&result](common::diagnostics_t::proxy_t proxy)
{
proxy << "endpoint found";
for (auto const& j : result->params.map())
proxy << "\n -> " << j.first << " = " << j.second << '\n';
};
trace_endpoint(trace());
req.extensions().extend(&res.memory().alloc(result->params));
result->handler.invoke(req, res);
}
void
router_t::
operator()(server::request_t& req, server::response_t& res) const
{
on_request(req, res);
}
common::diagnostics_t::proxy_t
router_t::
trace() const
{
return diagnostics_ << routing_category();
}
} // namespace seafire::routing

View File

@ -0,0 +1,40 @@
#ifndef seafire__routing__router_hxx_
#define seafire__routing__router_hxx_
#include <seafire/routing/diagnostics.hxx>
#include <seafire/routing/routing-table.hxx>
#include <seafire/common/diagnostics.hxx>
#include <seafire/server/request.hxx>
#include <seafire/server/response.hxx>
namespace seafire::routing
{
class router_t
{
public:
router_t(common::diagnostics_t&, routing_table_t);
routing_table_t const&
routing_table() const;
void
on_request(server::request_t&, server::response_t&) const;
void
operator()(server::request_t&, server::response_t&) const;
private:
common::diagnostics_t::proxy_t
trace() const;
common::diagnostics_t& diagnostics_;
routing_table_t rt_;
};
} // namespace seafire::routing
#endif

View File

@ -0,0 +1,85 @@
#include <seafire/routing/routing-table.hxx>
#include <seafire/routing/match-path.hxx>
#include <seafire/routing/flatten-route.hxx>
namespace 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::
find_route(std::string const& path) const
{
for (auto const& e : endpoints()) {
route_parameters_t params;
if (match_path(e.pattern(), path, params))
return find_result_t{e.handler(), std::move(params)};
}
return {};
}
routing_table_t::builder_t::
builder_t() = default;
routing_table_t::builder_t::
~builder_t() noexcept = default;
route_t&
routing_table_t::builder_t::
add_route()
{
roots_.emplace_back();
return roots_.back();
}
route_t&
routing_table_t::builder_t::
add_route(route_t r)
{
roots_.emplace_back(std::move(r));
return roots_.back();
}
route_t&
routing_table_t::builder_t::
add_route(std::string path)
{
return add_route(route_t{std::move(path)});
}
route_t&
routing_table_t::builder_t::
add_route(std::string path,
server::request_handler_t handler)
{
return add_route({std::move(path), std::move(handler)});
}
routing_table_t
routing_table_t::builder_t::
build() const
{
std::vector<endpoint_t> endpoints;
for (auto const& r : roots_) {
flatten_route(endpoints, r);
}
return routing_table_t{std::move(endpoints)};
}
} // namespace seafire::routing

View File

@ -0,0 +1,78 @@
#ifndef seafire__routing__routing_table_hxx_
#define seafire__routing__routing_table_hxx_
#include <seafire/routing/endpoint.hxx>
#include <seafire/routing/route-parameters.hxx>
#include <seafire/routing/route.hxx>
#include <seafire/server/request-handler.hxx>
#include <list>
#include <optional>
#include <string>
#include <vector>
namespace seafire::routing
{
class routing_table_t
{
public:
class builder_t;
struct find_result_t
{
server::request_handler_t const& handler;
route_parameters_t params;
};
explicit
routing_table_t(std::vector<endpoint_t>);
std::vector<endpoint_t> const&
endpoints() const;
std::optional<find_result_t>
find_route(std::string const&) const;
private:
std::vector<endpoint_t> endpoints_;
};
class routing_table_t::builder_t {
public:
builder_t();
builder_t(builder_t const&) = delete;
builder_t(builder_t&&) = delete;
~builder_t() noexcept;
route_t&
add_route();
route_t&
add_route(route_t);
route_t&
add_route(std::string);
route_t&
add_route(std::string, server::request_handler_t);
routing_table_t
build() const;
builder_t& operator=(builder_t const&) = delete;
builder_t& operator=(builder_t&&) = delete;
private:
std::list<route_t> roots_;
};
} // namespace seafire::routing
#endif

View File

@ -0,0 +1,37 @@
#ifndef seafire__routing__version_hxx_
#define seafire__routing__version_hxx_
// The numeric version format is AAAAABBBBBCCCCCDDDE where:
//
// AAAAA - major version number
// BBBBB - minor version number
// CCCCC - bugfix version number
// DDD - alpha / beta (DDD + 500) version number
// E - final (0) / snapshot (1)
//
// When DDDE is not 0, 1 is subtracted from AAAAABBBBBCCCCC. For example:
//
// Version AAAAABBBBBCCCCCDDDE
//
// 0.1.0 0000000001000000000
// 0.1.2 0000000001000020000
// 1.2.3 0000100002000030000
// 2.2.0-a.1 0000200001999990010
// 3.0.0-b.2 0000299999999995020
// 2.2.0-a.1.z 0000200001999990011
//
#define SEAFIRE_ROUTING_VERSION $seafire_routing.version.project_number$ULL
#define SEAFIRE_ROUTING_VERSION_STR "$seafire_routing.version.project$"
#define SEAFIRE_ROUTING_VERSION_ID "$seafire_routing.version.project_id$"
#define SEAFIRE_ROUTING_VERSION_FULL "$seafire_routing.version$"
#define SEAFIRE_ROUTING_VERSION_MAJOR $seafire_routing.version.major$
#define SEAFIRE_ROUTING_VERSION_MINOR $seafire_routing.version.minor$
#define SEAFIRE_ROUTING_VERSION_PATCH $seafire_routing.version.patch$
#define SEAFIRE_ROUTING_PRE_RELEASE $seafire_routing.version.pre_release$
#define SEAFIRE_ROUTING_SNAPSHOT_SN $seafire_routing.version.snapshot_sn$ULL
#define SEAFIRE_ROUTING_SNAPSHOT_ID "$seafire_routing.version.snapshot_id$"
#endif

8
tests/.gitignore vendored Normal file
View File

@ -0,0 +1,8 @@
# Test executables.
#
driver
# Testscript output directories (can be symlinks).
#
test
test-*

4
tests/build/.gitignore vendored Normal file
View File

@ -0,0 +1,4 @@
/config.build
/root/
/bootstrap/
build/

View File

@ -0,0 +1,5 @@
project = # Unnamed tests subproject.
using config
using test
using dist

16
tests/build/root.build Normal file
View File

@ -0,0 +1,16 @@
cxx.std = latest
using cxx
hxx{*}: extension = hxx
ixx{*}: extension = ixx
txx{*}: extension = txx
cxx{*}: extension = cxx
# Every exe{} in this subproject is by default a test.
#
exe{*}: test = true
# The test target for cross-testing (running tests under Wine, etc).
#
test.target = $cxx.target

1
tests/buildfile Normal file
View File

@ -0,0 +1 @@
./: {*/ -build/}