Loco is a web and API framework running on Rust.
This is a chatroom example to show how websockets are implemented.
Note that this is not a regular WebSocket application, you'll need to use socket.io on the client side to get this to work. Socket.io supports long-polling fallbacks, rooms, and other things that raw WebSockets don't support. See Axum websocket example for inspiration for building a pure WebSocket application.
cargo loco start
$ cargo loco start
Finished dev [unoptimized + debuginfo] target(s) in 21.63s
Running `target/debug/myapp start`
:
:
:
controller/app_routes.rs:203: [Middleware] Adding log trace id
β β
β β
β β β β ββ
β βββ
β β β βββββ
βββ
βββββββ βββββββββ βββββββββββ βββββββββ βββ
ββββββ βββββ βββ βββββ βββ βββββ βββ ββ
ββββββ βββββ βββ βββββ βββ βββββ βββ βββ
ββββββ βββββ βββ βββββ βββββ βββ βββββ
ββββββ βββββ βββ βββββ βββ βββββ βββ βββββ
ββββββ βββββ βββ ββββ βββ βββββ βββ βββββ
ββββββ ββββββββββ ββββββββββ ββββββββββ βββ
βββββββββββββββββββββββββββββββββββββββ
https://loco.rs
environment: development
database: automigrate
logger: debug
compilation: debug
modes: server
listening on http://localhost:5150
You can check your configuration to pick either frontend setup or server-side rendered template, and activate the relevant configuration sections.
Check out a quick tour or the complete guide.