2 releases
0.1.1 | Mar 30, 2023 |
---|---|
0.1.0 | Mar 30, 2023 |
#283 in WebSocket
23 downloads per month
18KB
324 lines
Stetson
Stetson is a pure rust pubsub server over HTTP websockets.
Use it vanilla or fork it and make your own modifications.
Usage
Install the binary
cargo install stetson
Run the server, making sure to set a publisher key
echo "PUBLISH_KEY=$(openssl rand -hex 24)" > .env ; stetson
You can find the publisher key that was generated in the previous step in the .env
file
cat .env
Requests
subscribe
{ "subscribe": { "topics": ["sports", "weather"] } }
unsubscribe
{ "unsubscribe": { "topics": ["sports"] } }
publish
{ "publish": { "topics": ["weather"], "message": "storms ahead", "key": "..." } }
Responses
message
- received when a new message from a subscribed topic is received
{ "message": { "topic": "weather", "message": "storms ahead" } }
error
- received when there was en error publishing a message
{ "error": { "message": "some error message here" } }
License
Licensed under either of
- Apache License, Version 2.0 (LICENSE-APACHE or http://www.apache.org/licenses/LICENSE-2.0)
- MIT license (LICENSE-MIT or http://opensource.org/licenses/MIT)
Dependencies
~12–20MB
~275K SLoC