snapkitty
developer-tools
c++
File size: 2,003 Bytes
0196580
 
 
6aef5ff
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
% SPDX-License-Identifier: LicenseRef-Sovereign-Leviathan-SL-AGPL3-001
% Licensing: see LICENSE in the repository root.

%%%-------------------------------------------------------------------
%%% @doc Cowboy route table for all six required API domains
%%% (`/agents', `/browser', `/search', `/messages', `/events',
%%% `/health') plus the static frontend assets.
%%% @end
%%%-------------------------------------------------------------------
-module(hk_api_router).

-export([dispatch/0]).

dispatch() ->
    cowboy_router:compile([
        {'_', [
            {"/", cowboy_static, {priv_file, hyperkitty, "frontend/index.html"}},
            {"/js/[...]", cowboy_static, {priv_dir, hyperkitty, "frontend/js"}},

            {"/api/health", hk_api_health_h, []},

            {"/api/agents", hk_api_agents_h, collection},
            {"/api/agents/:id", hk_api_agents_h, item},
            {"/api/agents/:id/objective", hk_api_agents_h, objective},
            {"/api/agents/:id/actions", hk_api_agents_h, actions},
            {"/api/agents/:id/complete", hk_api_agents_h, complete},
            {"/api/agents/:id/terminate", hk_api_agents_h, terminate},

            {"/api/browser/sessions", hk_api_browser_h, collection},
            {"/api/browser/sessions/:id", hk_api_browser_h, item},
            {"/api/browser/sessions/:id/close", hk_api_browser_h, close},
            {"/api/browser/sessions/:id/tabs", hk_api_browser_h, tabs},
            {"/api/browser/sessions/:id/tabs/:tab_id/navigate", hk_api_browser_h, navigate},
            {"/api/browser/sessions/:id/tabs/:tab_id/actions", hk_api_browser_h, actions},

            {"/api/search", hk_api_search_h, collection},
            {"/api/search/:id", hk_api_search_h, item},
            {"/api/search/:id/result", hk_api_search_h, result},

            {"/api/messages", hk_api_messages_h, []},

            {"/api/events/recent", hk_api_events_recent_h, []},
            {"/api/events/stream", hk_api_events_ws_h, []}
        ]}
    ]).