httpfile

Crates.iohttpfile
lib.rshttpfile
version0.1.1
sourcesrc
created_at2022-08-19 23:58:42.085834
updated_at2022-08-20 00:04:09.026229
descriptionCodegen module for http file
homepagehttps://servicex.sh/
repositoryhttps://github.com/servicex-sh/httpfile-rs
max_upload_size
id648965
size4,403
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