lemunozm / message-io

Fast and easy-to-use event-driven network library.
Apache License 2.0
1.12k stars 75 forks source link

Sending HTTP Responses #127

Closed shaoruu closed 2 years ago

shaoruu commented 2 years ago

Hi,

Thanks for the great library!

I just wanted to ask if it is possible to send HTML/JSON responses back to a client, or even host static files with this library?

Thanks!

lemunozm commented 2 years ago

Hi @shaoruu, thanks!

It is possible if you use the Transport::Tcp and handle the stream of data by yourself. Although if you want to make some HTTP service maybe is better to use something like rocket or actix crates. I say that because message-io is more low-level oriented and could be tedious to handle the HTTP protocol by yourself, although possible.

shaoruu commented 2 years ago

Thank's for the response!

I decided to rewrite my app in Actix eventually. I did get Transport::Tcp working to serve static folders, but I couldn't get it to serve on the same port as the web socket. Still, very nice crate though!