Skip to main content

haystack_server/ops/
mod.rs

1//! Haystack HTTP API op handlers and route registration.
2//!
3//! Each sub-module implements one or more Haystack ops as async Actix-Web
4//! handler functions. The [`configure`] function registers all routes under
5//! the `/api` scope.
6//!
7//! Standard ops: `about`, `ops`, `formats`, `read`, `nav`, `defs`, `libs`,
8//! `watchSub`/`watchPoll`/`watchUnsub`, `hisRead`/`hisWrite`,
9//! `pointWrite`, `invokeAction`, `close`.
10//!
11//! Extended ops: `changes`, `export`/`import`, `specs`/`spec`/`loadLib`/
12//! `unloadLib`/`exportLib`/`validate`, `system/status`/`backup`/`restore`,
13//! `federation/status`/`sync`, `rdf/turtle`/`rdf/jsonld`.
14
15pub mod about;
16pub mod changes;
17pub mod data;
18pub mod defs;
19pub mod federation;
20pub mod formats;
21pub mod graph;
22pub mod his;
23pub mod invoke;
24pub mod libs;
25pub mod nav;
26pub mod ops_handler;
27pub mod point_write;
28pub mod rdf;
29pub mod read;
30pub mod system;
31pub mod watch;
32
33use actix_web::web;
34
35/// Configure all Haystack API routes under `/api`.
36pub fn configure(cfg: &mut web::ServiceConfig) {
37    cfg.service(
38        web::scope("/api")
39            .route("/about", web::get().to(about::handle))
40            .route("/ops", web::get().to(ops_handler::handle))
41            .route("/formats", web::get().to(formats::handle))
42            .route("/read", web::post().to(read::handle))
43            .route("/changes", web::post().to(changes::handle))
44            .route("/nav", web::post().to(nav::handle))
45            .route("/defs", web::post().to(defs::handle))
46            .route("/libs", web::post().to(defs::handle_libs))
47            .route("/watchSub", web::post().to(watch::handle_sub))
48            .route("/watchPoll", web::post().to(watch::handle_poll))
49            .route("/watchUnsub", web::post().to(watch::handle_unsub))
50            .route("/pointWrite", web::post().to(point_write::handle))
51            .route("/hisRead", web::post().to(his::handle_read))
52            .route("/hisWrite", web::post().to(his::handle_write))
53            .route("/invokeAction", web::post().to(invoke::handle))
54            .route("/specs", web::post().to(libs::handle_specs))
55            .route("/spec", web::post().to(libs::handle_spec))
56            .route("/loadLib", web::post().to(libs::handle_load_lib))
57            .route("/unloadLib", web::post().to(libs::handle_unload_lib))
58            .route("/exportLib", web::post().to(libs::handle_export_lib))
59            .route("/validate", web::post().to(libs::handle_validate))
60            .route("/export", web::post().to(data::handle_export))
61            .route("/import", web::post().to(data::handle_import))
62            .route("/rdf/turtle", web::get().to(rdf::handle_turtle))
63            .route("/rdf/jsonld", web::get().to(rdf::handle_jsonld))
64            .route("/close", web::post().to(about::handle_close))
65            .service(
66                web::scope("/system")
67                    .route("/status", web::get().to(system::handle_status))
68                    .route("/backup", web::post().to(system::handle_backup))
69                    .route("/restore", web::post().to(system::handle_restore)),
70            )
71            .service(
72                web::scope("/federation")
73                    .route("/status", web::get().to(federation::handle_status))
74                    .route("/sync", web::post().to(federation::handle_sync))
75                    .route("/sync/{name}", web::post().to(federation::handle_sync_one)),
76            )
77            .service(
78                web::scope("/graph")
79                    .route("/flow", web::post().to(graph::handle_flow))
80                    .route("/edges", web::post().to(graph::handle_edges))
81                    .route("/tree", web::post().to(graph::handle_tree))
82                    .route("/neighbors", web::post().to(graph::handle_neighbors))
83                    .route("/path", web::post().to(graph::handle_path))
84                    .route("/stats", web::get().to(graph::handle_stats)),
85            ),
86    );
87}