Expand description
cnctd_server — the HTTP + WebSocket framework behind cnctd.world and the other Connected Dot services.
The app implements RestRouter (one route(Request) -> Response call
per HTTP request) and optionally a SocketRouter (one call per inbound
WebSocket message), hands both to CnctdServer, and gets back: JSON
envelopes with the house macros, raw/binary/streaming/SSE responses,
redirects, a single-page-app fallback with per-path <head> tags, CORS,
a connection table with pub/sub push, and a heartbeat.
Nothing in the public API names the HTTP library underneath.
Re-exports§
pub use router::request::Request;pub use router::response::Response;pub use router::RestRouter;pub use router::SocketRouter;pub use server::CnctdServer;pub use server::RunningServer;pub use server::ServerConfig;pub use socket::connection::CnctdConnection;pub use socket::connection::Connections;pub use socket::fanout::Fanout;pub use socket::fanout::LocalOnly;pub use socket::SocketConfig;pub use cnctd_protocol;
Modules§
- auth
- router
- The two traits an app implements, and the request / response types that cross them.
- server
- Configure and run a server.
- socket
- The WebSocket endpoint: upgrade, per-connection send/receive loop,
disconnect hooks. The connection table itself is
connection. - utils
- Small helpers shared by the server and socket layers.
Macros§
- bad_
gateway - The envelope macros, usable as
cnctd_server::bad_request!etc. - bad_
request - The envelope macros, usable as
cnctd_server::bad_request!etc. - conflict
- The envelope macros, usable as
cnctd_server::bad_request!etc. - created
- The envelope macros, usable as
cnctd_server::bad_request!etc. - error_
response - The envelope macros, usable as
cnctd_server::bad_request!etc. - forbidden
- The envelope macros, usable as
cnctd_server::bad_request!etc. - internal_
server_ error - The envelope macros, usable as
cnctd_server::bad_request!etc. - method_
not_ allowed - The envelope macros, usable as
cnctd_server::bad_request!etc. - not_
found - The envelope macros, usable as
cnctd_server::bad_request!etc. - request_
timeout - The envelope macros, usable as
cnctd_server::bad_request!etc. - service_
unavailable - The envelope macros, usable as
cnctd_server::bad_request!etc. - success_
data - The envelope macros, usable as
cnctd_server::bad_request!etc. - success_
msg - The envelope macros, usable as
cnctd_server::bad_request!etc. - success_
response - The envelope macros, usable as
cnctd_server::bad_request!etc. - too_
many_ requests - The envelope macros, usable as
cnctd_server::bad_request!etc. - unauthorized
- The envelope macros, usable as
cnctd_server::bad_request!etc.
Structs§
- Bytes
- Raw request bodies are handed over as
Bytes. A cheaply cloneable and sliceable chunk of contiguous memory. - Connection
Info - A connection as the app sees it (and as it is pushed on
server-infoand in the optionalsocket/connectedfirst frame).
Enums§
- Connection
Format - Wire format a connection expects for push messages.
- Http
Method - The methods the API prefix answers. Anything else is a 405.
Attribute Macros§
- async_
trait - Routers are written with
#[cnctd_server::async_trait].