fed-sx-m1: Step 8d-dispatch-cap — capabilities_body_for + Accept-aware route + 13 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 32s
This commit is contained in:
@@ -10,7 +10,8 @@
|
||||
post_activity_response/0,
|
||||
validation_failed_response/0,
|
||||
cid_response/1,
|
||||
accept_format/1, accept_format_from/1]).
|
||||
accept_format/1, accept_format_from/1,
|
||||
capabilities_body_for/1]).
|
||||
|
||||
%% HTTP request router per design §16.1.
|
||||
%%
|
||||
@@ -43,6 +44,11 @@ route(Req, Cfg) ->
|
||||
case {M, P} of
|
||||
{<<80,79,83,84>>, <<47,97,99,116,105,118,105,116,121>>} ->
|
||||
handle_post_activity(Req, Cfg);
|
||||
{<<71,69,84>>,
|
||||
<<47,46,119,101,108,108,45,107,110,111,119,110,
|
||||
47,115,120,45,99,97,112,97,98,105,108,105,116,105,101,115>>} ->
|
||||
F = accept_format_from(Req),
|
||||
ok_response(capabilities_body_for(F));
|
||||
_ ->
|
||||
dispatch(M, P)
|
||||
end.
|
||||
@@ -356,3 +362,30 @@ accept_format_from(Req) ->
|
||||
not_found -> text
|
||||
end
|
||||
end.
|
||||
|
||||
%% capabilities_body_for/1 — content-negotiated capability bodies.
|
||||
%% Each format returns a distinct byte sequence so dispatch can be
|
||||
%% observed end-to-end. Real serialisation (JSON-LD, dag-cbor, etc.)
|
||||
%% lands once the corresponding encoder BIFs are wired; v1 uses
|
||||
%% tagged stubs that are syntactically the right shape.
|
||||
capabilities_body_for(text) ->
|
||||
capabilities_body();
|
||||
%% `{"caps":"fed-sx-m1"}\n` — 21 bytes
|
||||
capabilities_body_for(json) ->
|
||||
<<123,34,99,97,112,115,34,58,34,
|
||||
102,101,100,45,115,120,45,109,49,34,125,10>>;
|
||||
capabilities_body_for(activity_json) ->
|
||||
%% Same payload as :json — the difference is the Content-Type
|
||||
%% header (Step 8d-content-type follow-up); body shape matches.
|
||||
capabilities_body_for(json);
|
||||
%% `(caps "fed-sx-m1")\n` — 19 bytes
|
||||
capabilities_body_for(sx) ->
|
||||
<<40,99,97,112,115,32,34,
|
||||
102,101,100,45,115,120,45,109,49,34,41,10>>;
|
||||
%% A minimal CBOR map: 0xA1 0x64 "caps" 0x69 "fed-sx-m1"
|
||||
%% A1 = map(1); 64 = text(4) "caps"; 69 = text(9) "fed-sx-m1"
|
||||
capabilities_body_for(cbor) ->
|
||||
<<161,100,99,97,112,115,105,
|
||||
102,101,100,45,115,120,45,109,49>>;
|
||||
capabilities_body_for(_) ->
|
||||
capabilities_body().
|
||||
|
||||
Reference in New Issue
Block a user