Files
retoor 3c4334cec9 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.
2026-10-23 18:20:04 +02:00

27 lines
1.0 KiB
C++

// Route: GET /formats/data (content negotiation)
#include "support/Assert.hpp"
using namespace molo::example::test;
using molo::example::fw::Method;
int main() {
Fixture f;
auto def = f.client->get("/formats/data");
check(contains(def.headers.get("Content-Type"), "application/json"),
"default is json");
auto xml = f.client->request(Method::Get, "/formats/data", "",
{{"Accept", "application/xml"}});
check(contains(xml.headers.get("Content-Type"), "application/xml"),
"xml negotiated");
check(contains(xml.body, "<value>42</value>"), "xml body");
auto weighted = f.client->request(
Method::Get, "/formats/data", "",
{{"Accept", "text/html;q=0.2, text/plain;q=0.9"}});
check(contains(weighted.headers.get("Content-Type"), "text/plain"),
"q weights honored");
auto nope = f.client->request(Method::Get, "/formats/data", "",
{{"Accept", "image/png"}});
check(nope.status == 406, "no match is 406");
return finish("formats/data");
}