httpfile-build

Crates.iohttpfile-build
lib.rshttpfile-build
version0.1.1
sourcesrc
created_at2022-08-19 23:58:27.332294
updated_at2022-08-20 00:03:48.812339
descriptionCall http requests wrapper by http file
homepagehttps://servicex.sh/
repositoryhttps://github.com/servicex-sh/httpfile-rs
max_upload_size
id648964
size24,522
Libing Chen (linux-china)

documentation

https://servicex.sh/

README

httpfile-rs

How to get started?

  • Add dependencies in Cargo.toml:
[dependencies]
httpfile = "0.1"
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1.0", features = ["derive"] }
serde_json = "1.0"
tokio = { version = "1", features = ["full"] }
handlebars = "4"
lazy_static="1.4"

[build-dependencies]
httpfile-build = "0.1"
  • Create http file, such as index.http with following content:
### get my ip
//@name my-ip
GET https://httpbin.org/ip
User-Agent: curl/7.47.0
  • Create a Rust module, such as httpbin.rs with following content:
// this would include code generated for package hello from .http file
httpfile::include_http!("index");
  • Add following code to build.rs:
httpfle::configure()
        .httpfile("index.http")
        .compile()
        .unwrap();
  • Call http requests in your code:
let response = httpbin::my_ip().await?;

References

Commit count: 36

cargo fmt