DEV Community

El Bruno for Microsoft Azure

Posted on • Originally published at elbruno.com on

#Rust πŸ¦€ – Learning HTTP GET and POST requests in Rust, and yes this is a β€œπŸŒWhat’s my IP” demo πŸ˜„

Hi !

Yes, I’m starting to use OpenAI services in with Rust. However, before getting here, I spent some time learning how to work with HTTP Requests in Rust.

There seems to be several libraries that can help. I found several examples using [https://docs.rs/reqwest/0.6.2/reqwest/], so I decided to use this one.

A classic example to do this, is to perform an HTTP GET request to the following url, to get our public IP Address.


https://httpbin.org/ip

Enter fullscreen mode Exit fullscreen mode

And hey, the code is super simple

With a more simple output


    Finished dev [unoptimized + debuginfo] target(s) in 3.99s
     Running `target\debug\result02.exe`
{
    "origin": "111.111.111.111",
}

Enter fullscreen mode Exit fullscreen mode

More about http calls in next posts!

Happy coding!

Greetings

El Bruno

More posts in my blog ElBruno.com.


Top comments (0)