All Projects → zupzup → warp-websockets-example

zupzup / warp-websockets-example

Licence: MIT license
Basic example using websockets with warp in Rust

Programming Languages

rust
11053 projects
Makefile
30231 projects

warp-websockets-example

Basic example using websockets with warp in Rust

Run with

make dev

Then, you can register/unregister a client:

curl -X POST 'http://localhost:8000/register' -H 'Content-Type: application/json' -d '{ "user_id": 1 }' 

curl -X DELETE 'http://localhost:8000/register/e2fa90682255472b9221709566dbceba' 

Or connect to the WebSocket using the returned URL: ws://127.0.0.1:8000/ws/625ac78b88e047a1bc7b3f8459702078.

Then, you can publish messages using

curl -X POST 'http://localhost:8000/publish' \
    -H 'Content-Type: application/json' \
    -d '{"user_id": 1, "topic": "cats", "message": "are awesome"}'
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].