#http #test #header #configuration #serve #url #tube

tubetti

Serve &[u8] data at a localhost url with minimal configuration

7 releases

Uses new Rust 2024

new 0.0.7 Mar 19, 2025
0.0.6 Mar 18, 2025
0.0.5 Feb 23, 2025

#196 in Testing

Download history 199/week @ 2025-02-11 551/week @ 2025-02-18 549/week @ 2025-02-25 434/week @ 2025-03-04 373/week @ 2025-03-11

1,932 downloads per month

MIT/Apache

16KB
216 lines

Tubetti: small http tubes

No-fuss, low configuration webservers on demand

Features:

  • Convenience-focused development experience
  • Axum-based, can optionally be constructed from a Router
  • Supports ranged requests using axum-range
  • Supports custom headers using HeaderMap

Example Usage

        // most convenient, configure a tube with just bytes on a randomly
        // selected unused port:
        let _tb = tube!("potatoes".as_bytes()).await.unwrap();

        // configure a tube with bytes, custom headers and port:
        let _tb_opt = tube!("tomatoes".as_bytes(), HeaderMap::new(), 2323).await.unwrap();

        // "advanced configuration": use the construct w/ a hand-rolled
        // axum app:
        let mut headers = crate::axum::http::HeaderMap::new();
        headers.append("pasta", crate::axum::http::HeaderValue::from_static("yum"));
        let body = "happy valentine's day".as_bytes();
        let app = crate::axum::Router::new()
            .route("/", crate::axum::routing::get(Tube::serve_ranged_request))
            .with_state((Body::new(body), headers));
        let majestic_tubes = Tube::new(app, Some(2323)).await.unwrap();

Caveats:

  • Under active development, expect breaking changes per-release until stable

Example usage:

License

MIT OR Apache-2.0

Dependencies

~6–13MB
~158K SLoC