feat: implement MoloApp plans 01-15 with integration
Full C++23 framework tree: runtime, observability, security, data, app, realtime, supervisor, clients, CLI, example plus enterprise tenancy, audit, operability, governance, supplychain. Postgres via docker compose for tests.
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
#include "App.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", "/views/greet"},
|
||||
{"routers", "/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"},
|
||||
{"ai", "/cli/ai"},
|
||||
{"workflow", "/workflow/release"},
|
||||
{"redirect", "/redirect/here"},
|
||||
{"health", "/health"},
|
||||
};
|
||||
|
||||
} // namespace
|
||||
|
||||
void register_index(fw::Router& router, Services& services) {
|
||||
fw::Environment* env = services.templates.get();
|
||||
router.get("/", "index", [env](fw::Request req) {
|
||||
fw::TemplateCtx ctx;
|
||||
ctx["title"] = std::string("MoloApp living example");
|
||||
ctx["show_matrix"] = std::string("true");
|
||||
fw::TemplateList rows;
|
||||
for (const auto& [feature, route] : kFeatures) {
|
||||
rows.push_back({{"feature", feature}, {"route", route}});
|
||||
}
|
||||
ctx["matrix"] = rows;
|
||||
(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
|
||||
Reference in New Issue
Block a user