Axum
WebSockets
Learn how websockets can upgrade your web service by providing live update functionality, using Axum.
Description
This example shows how to use a WebSocket to show the live status of the Shuttle API on a web page.
There are a few routes available:
/
- the homepage route where you can find theindex.html
page./ws
- the route that handles websockets.
You can clone the example below by running the following (you’ll need shuttle
CLI installed):
Code
Usage
Once you’ve cloned the example, launch it locally using shuttle run
and then go to http://localhost:8000
. You should be able to see a status page and if you go to your Inspect/Chrome Devtools (depending on what browser you’re using), if you go to the Network tab you’ll see that your browser received a HTTP status code of 101.
If you want to explore other frameworks, we have more examples with popular ones like Tower and Warp. You can find them right here.
Be sure to check out the examples repo for many more examples!
Was this page helpful?