Add link to UI in root page

This commit is contained in:
Martchus 2022-05-01 22:21:42 +02:00
parent 5699895a37
commit 1950619f21
2 changed files with 12 additions and 5 deletions

View File

@ -52,6 +52,11 @@ inline std::shared_ptr<Response> makeText(const Request &request, std::string &&
return makeData(request, std::move(text), "text/plain");
}
inline std::shared_ptr<Response> makeHtml(const Request &request, const std::string &text)
{
return makeData(request, text, "text/html");
}
inline std::shared_ptr<Response> makeHtml(const Request &request, std::string &&text)
{
return makeData(request, std::move(text), "text/html");

View File

@ -36,19 +36,21 @@ void getRoot(const Params &params, ResponseHandler &&handler)
{
static const auto routes([] {
stringstream ss;
ss << "Available routes:\n";
ss << "<title>Build service</title>"
"<p>Available routes:</p><ul>"
"<li><a href=\"index.html\">UI</a></li>";
for (const auto &route : Server::router()) {
const auto method(boost::beast::http::to_string(route.first.method));
ss << method;
ss << "<li><pre>" << method;
for (auto i = method.size(); i < 5; ++i) {
ss << ' ';
}
ss << route.first.path << '\n';
ss << route.first.path << "</pre></li>";
}
ss << "\nNote: curl -X GET/POST http://...\n";
ss << "</ul>";
return ss.str();
}());
handler(makeText(params.request(), routes));
handler(makeHtml(params.request(), routes));
}
void getVersion(const Params &params, ResponseHandler &&handler)