- New rootless doos container runtime: sandbox, cgroup, network, images, hardening, davmount, CLI plus molo integration - 18 CVE audit reproductions with READMEs and Makefiles - Example DoosDemo routes, IndexCatalog, static assets, spec update - CLI serve on 0.0.0.0:8000, arg parser, dev server improvements - Runtime HTTP fixes, supervisor isolation backend - Tests for doos, example doos routes, CLI serve; suite count 261 to 265
83 lines
2.7 KiB
C++
83 lines
2.7 KiB
C++
#include "App.hpp"
|
|
#include "IndexCatalog.hpp"
|
|
|
|
#include "../fw/Http.hpp"
|
|
#include "../fw/Router.hpp"
|
|
#include "../fw/Templates.hpp"
|
|
|
|
namespace molo::example::app {
|
|
|
|
namespace {
|
|
|
|
const char* kFeatures[][2] = {
|
|
{"routing", "/routing/hello/world"},
|
|
{"views", "/routing/views/greet"},
|
|
{"routers", "/routing/routers/nested/deep"},
|
|
{"chaining", "/app1/app1/app1/whoami"},
|
|
{"orm-sqlite", "/orm/users?backend=sqlite"},
|
|
{"orm-postgres", "/orm/users?backend=postgres"},
|
|
{"auth", "/auth/me"},
|
|
{"sessions", "/sessions/counter"},
|
|
{"forms", "/forms/contact"},
|
|
{"validation", "/validate/user"},
|
|
{"templates", "/templates/page"},
|
|
{"formats", "/formats/data"},
|
|
{"static", "/static/app.css"},
|
|
{"embedded", "/embedded/hello.txt"},
|
|
{"streaming", "/streaming/feed"},
|
|
{"passthrough", "/streaming/passthrough"},
|
|
{"websocket", "/ws/chat"},
|
|
{"socketio", "/socketio/rooms"},
|
|
{"sse", "/sse/events"},
|
|
{"pubsub", "/pubsub/publish"},
|
|
{"events", "/events/fire"},
|
|
{"metrics", "/metrics/counters"},
|
|
{"telemetry", "/telemetry/trace"},
|
|
{"kv", "/kv/items"},
|
|
{"cache", "/cache/lookup"},
|
|
{"uploads", "/uploads/file"},
|
|
{"webdav", "/webdav/files/"},
|
|
{"replication", "/replication/state"},
|
|
{"tasks", "/supervisor/tasks"},
|
|
{"workers", "/supervisor/workers"},
|
|
{"restclient", "/restclient/self"},
|
|
{"openapi", "/openapi.json"},
|
|
{"docs", "/docs"},
|
|
{"doos", "/doos"},
|
|
{"doos-status", "/doos/status"},
|
|
{"ai", "/cli/ai"},
|
|
{"workflow", "/workflow/release"},
|
|
{"redirect", "/redirect/here"},
|
|
{"health", "/health"},
|
|
{"locust", "http://localhost:8089"},
|
|
};
|
|
|
|
} // namespace
|
|
|
|
void register_index(fw::Router& router, Services& services_ref) {
|
|
fw::Environment* env = services_ref.templates.get();
|
|
Services* services = &services_ref;
|
|
static const IndexCatalog catalog;
|
|
router.get("/", "index", [env, services](fw::Request req) {
|
|
fw::TemplateCtx ctx;
|
|
ctx["title"] = std::string("MoloApp living example");
|
|
std::vector<std::pair<std::string, std::string>> rows;
|
|
for (const auto& [feature, route] : kFeatures) rows.emplace_back(feature, route);
|
|
for (const auto& [feature, route] : services->features) rows.emplace_back(feature, route);
|
|
std::size_t features = 0, groups = 0;
|
|
ctx["sections"] = catalog.render(rows, &features, &groups);
|
|
ctx["feature_count"] = std::to_string(features);
|
|
ctx["group_count"] = std::to_string(groups);
|
|
(void)req;
|
|
return fw::Response(200, env->render("index.html", ctx),
|
|
"text/html; charset=utf-8");
|
|
});
|
|
router.get("/health", "health", [](fw::Request req) {
|
|
(void)req;
|
|
return fw::JsonResponse(
|
|
"{\"status\":\"ok\",\"tls\":\"stub-no-wolfssl\"}", 200);
|
|
});
|
|
}
|
|
|
|
} // namespace molo::example::app
|