Websocket + http server example


#1

How can I serve static files, and route request for serving html at ‘/’ and websocket handler at ‘/ws’, for example? It could be good tutorial for using hyper + ws + tokio


#2

I don’t know of any good tutorials on using hyper + ws + tokio, but I know mdbook use ws and synchronous hyper to serve a book locally. It’s probably not the prettiest code, but you may be able to use that as an example.

EDIT: I just realised that ws have a guide on their website. You may want to give that a shot.


#3

Yeah, it’s good for setting up ws-server, but main idea is using 1 async server for both - websockets and simple http requests.