rustolio_utils/http/mod.rs
1//
2// SPDX-License-Identifier: MPL-2.0
3//
4// Copyright (c) 2026 Tobias Binnewies. All rights reserved.
5//
6// This Source Code Form is subject to the terms of the Mozilla Public
7// License, v. 2.0. If a copy of the MPL was not distributed with this
8// file, You can obtain one at http://mozilla.org/MPL/2.0/.
9//
10
11//! HTTP request and response handling for the browser & server environment.
12//!
13//! # Browser Example
14//! (Ignore because of dependency cycle)
15//! ``` ignore
16//! use rustolio::prelude::*;
17//! use rustolio::utils::http::Request;
18//!
19//! #[derive(Debug, Clone, PartialEq, serde::Serialize, serde::Deserialize)]
20//! struct Data {
21//! field1: String,
22//! }
23//!
24//! fn fetch_component() -> Elements {
25//! let data: Signal<Option<Data>> = Signal::new(None);
26//!
27//! spawn(async move {
28//! let res = Request::get("https://api.example.com/data")
29//! .fetch()
30//! .await
31//! .unwrap()
32//! .json::<Data>()
33//! .await
34//! .unwrap()
35//! .into_body();
36//! data.set(Some(res));
37//! });
38//!
39//! elements! {
40//! move || {
41//! let Some(data) = data.value() else {
42//! return "Loading...".to_string();
43//! };
44//! data.field1
45//! }
46//! }
47//! }
48//! ```
49//!
50
51mod error;
52mod headers;
53mod incoming;
54mod method;
55mod outgoing;
56mod status;
57mod uri;
58mod version;
59
60pub mod request;
61pub mod response;
62
63pub use error::{Error, Result};
64pub use headers::{HeaderName, HeaderValue};
65pub use incoming::Incoming;
66pub use method::Method;
67pub use outgoing::Outgoing;
68pub use request::Request;
69pub use response::Response;
70pub use status::StatusCode;
71pub use uri::Uri;
72pub use version::Version;
73
74// use the builder as inner
75
76// #[cfg(any(test, target_arch = "wasm32"))]
77// mod tests {
78// use super::*;
79
80// // does not need to be run, testing compilation
81// fn test_request_builder() {
82// let req = Request::get("").body(());
83// }
84// }