Module socketioxide::layer
source · Expand description
A tower [Layer] for socket.io so it can be used as a middleware with frameworks supporting layers.
Example with axum :
// Create a socket.io layer
let (layer, io) = SocketIo::new_layer();
// Add io namespaces and events...
let app = axum::Router::<()>::new()
.route("/", get(|| async { "Hello, World!" }))
.layer(layer);
// Spawn axum server
Example with salvo :
#[handler]
async fn hello() -> &'static str {
"Hello World"
}
// Create a socket.io layer
let (layer, io) = SocketIo::new_layer();
// Add io namespaces and events...
let layer = layer.compat();
let router = Router::with_path("/socket.io").hoop(layer).goal(hello);
// Spawn salvo serverStructs
- A [
Layer] forSocketIoService, acting as a middleware.