Crate teahttp

Source
Expand description

§teahttp

Very simple but work well for WASM environment. As many http client tend to screw up WebWorker global, this ehttp inspired crate is to help. Although it seems to be a good alt, many things considerably manual.

Few example to figure things out

    TeaRequest::get("/api/something")
       .invoke()
       .await? // web_sys::Response

    let some_body = b"lorem ipsum dolor si amet";
    TeaRequest::post("/api/upload")
        .header("Content-Length", some_body)?
        .slice_body(some_body.as_slice() /* &[u8] */)
        .invoke()
        .await?

    TeaRequest::post("/api/submit")
        .header("Content-Length", &12.to_string())?
        .str_body("Hello World!" /* &str */)
        .invoke()
        .await?

Have fun

Re-exports§

pub use web_sys;

Structs§

TeaBuilder
Step to build options from TeaRequest
TeaRequest
Use this struct to construct your request
TeaWithBody
Request after TeaBuilder attach body. Should only TeaRequestInvoker::invoke

Enums§

TeaError
Handling mostly JS side error

Traits§

TeaHeaderOwner
Add header to request
TeaRequestBuilder
Finalize request by assign body
TeaRequestInvoker
Trait to actually invoke web request