fed-sx-m1: Step 8c-cap — GET /.well-known/sx-capabilities route + 8 tests
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
Some checks failed
Test, Build, and Deploy / test-build-deploy (push) Failing after 23s
This commit is contained in:
@@ -1,5 +1,7 @@
|
||||
-module(http_server).
|
||||
-export([route/1, ok_response/1, not_found_response/0, welcome_body/0]).
|
||||
-export([route/1, ok_response/1, not_found_response/0,
|
||||
welcome_body/0, capabilities_body/0,
|
||||
capabilities_path/0]).
|
||||
|
||||
%% HTTP request router per design §16.1.
|
||||
%%
|
||||
@@ -27,6 +29,11 @@ route(Req) ->
|
||||
%% 71 69 84 = "GET" | 47 = "/"
|
||||
dispatch(<<71, 69, 84>>, <<47>>) ->
|
||||
ok_response(welcome_body());
|
||||
%% GET /.well-known/sx-capabilities
|
||||
dispatch(<<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>>) ->
|
||||
ok_response(capabilities_body());
|
||||
dispatch(_, _) ->
|
||||
not_found_response().
|
||||
|
||||
@@ -35,6 +42,25 @@ dispatch(_, _) ->
|
||||
welcome_body() ->
|
||||
<<102,101,100,45,115,120,32,107,101,114,110,101,108,32,109,49,10>>.
|
||||
|
||||
%% "/.well-known/sx-capabilities" — exposed for callers that build
|
||||
%% requests in tests or that need the canonical path string.
|
||||
capabilities_path() ->
|
||||
<<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>>.
|
||||
|
||||
%% Capability descriptor body. Returned as plain text per design
|
||||
%% §16; future content-negotiation work (Step 8d) layers JSON /
|
||||
%% dag-cbor / SX representations on top.
|
||||
%%
|
||||
%% Lines (each terminated by \n = 10):
|
||||
%% "kernel: fed-sx-m1\n"
|
||||
%% "version: 0.0.1\n"
|
||||
%% "verbs: Create Update Delete\n"
|
||||
capabilities_body() ->
|
||||
<<107,101,114,110,101,108,58,32,102,101,100,45,115,120,45,109,49,10,
|
||||
118,101,114,115,105,111,110,58,32,48,46,48,46,49,10,
|
||||
118,101,114,98,115,58,32,67,114,101,97,116,101,32,85,112,100,97,116,101,32,68,101,108,101,116,101,10>>.
|
||||
|
||||
ok_response(Body) ->
|
||||
[{status, 200}, {headers, []}, {body, Body}].
|
||||
|
||||
|
||||
Reference in New Issue
Block a user