Skip to main content

Crate cnctd_server

Crate cnctd_server 

Source
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.
ConnectionInfo
A connection as the app sees it (and as it is pushed on server-info and in the optional socket/connected first frame).

Enums§

ConnectionFormat
Wire format a connection expects for push messages.
HttpMethod
The methods the API prefix answers. Anything else is a 405.

Attribute Macros§

async_trait
Routers are written with #[cnctd_server::async_trait].