FeignHTTP
FeignHTTP is a declarative HTTP client. Based on rust macros.
Features
- Easy to use
- Asynchronous request
- Configurable timeout settings
- Supports plain text, form, multipart and JSON
- Selectable HTTP backends (reqwest, reqwest-middleware or isahc)
Usage
FeignHTTP mark macros on asynchronous functions, you need a runtime for support async/await. You can use tokio.
tokio:
[]
= { = "1", = ["full"] }
Add feignhttp in your Cargo.toml and use default feature:
= { = "0.6" }
Then add the following code:
use get;
async
async
The get attribute macro specifies get request, feignhttp::Result<String> specifies the return result.
It will send get request to https://api.github.com and receive a plain text body.
Using non-default HTTP backend:
= { = "0.6", = false, = ["isahc-client"] }
The default-features = false option disable default reqwest.
For more examples, click here.
Documentation
Read the documentation for more details.
License
FeignHTTP is provided under the MIT license. See LICENSE.