For as a server you might want to inspect a requests uri to dispatch it use httprequest, response fn response(req request()) - httpresultresponse() match req. Index(req), foo foo(req) изучим запросы get и post, отображение http-ответа на предопределенную структуру и нюансы обработки различных кодов состояния http. This article is part of a chapter of rust web development which didnt make the cut to be in the book. We look at an example where a browser application is sending a http request to our web service which is written in rust. We will dive shortly into how exactly the bytes arrive at the kernel, and how our rust application is getting the bytes delivered into the running application. Contribute to hyperiumhttp development by creating an account on github.
More information about this crate can be found in the crate documentation. Next, add this to your crate use httprequest, response fn main() . This answer proposes using c to do http, but pure rust solutions are more appropriate because they are simpler for a team to maintain, and also because rust is safer than c. This would be much better than the other answer since it avoids dealing with futures, one of the most overly complicated, non-documented things i have ever seen. Too bad it doesnt work since there is no curlhttp available (anymore) - only something called easy which is way to complicated on its own and barely documented.
However, if you are rather starting from scratch, you will need to create a new project prior you add the code to make an http request in rust. Note this project uses cargo cli which is installed when installing rust. If you havent installed rust in your local machine, follow the instructions to install rust mentioned here before you continue following this tutorial. Rust makes it easy to create a new project using the cargo new command. .