Skip to content

project-snek/websocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

1 Commit
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

warp-websockets-example

Basic example using websockets with warp in Rust

Run with

docker-compose up --build

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.

websocat -t ws://127.0.0.1:8000/ws/2fd7f6e2e3294057b714c6c1c5aa827d
{ "topics": ["cats", "dogs"] }

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"}'

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published