CalebEverett / arloader

Rust command line application and client for uploading files to Arweave.
Apache License 2.0
83 stars 23 forks source link

allow customization in client #34

Open Dev43 opened 2 years ago

Dev43 commented 2 years ago

This PR allows for the customization of the reqwest client that the arweave struct uses. This way I can pass custom headers to all the requests in an easy manner such as this:

        let mut headers = header::HeaderMap::new();
        headers.insert(
            "X-Network",
            header::HeaderValue::from_static("arweave.testnet"),
        );
        let mut builder = Client::builder();
        builder = builder.default_headers(headers);

        let c = builder.build().unwrap();

        let r = c
            .get("http://localhost:1984/tx/ready_for_mining")
            .header("Content-Type", "application/x-www-form-urlencoded")
            .send()
            .await?
            .text()
            .await?;

Also added actual methods for last_tx and tx_anchor

Thanks for this lib :)