hitbox-http 0.2.1

Cacheable HTTP Request and Response
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use bytes::Bytes;
use hitbox::Extractor;
use hitbox_http::extractors::{NeutralExtractor, path::PathExtractor};
use hitbox_http::{BufferedBody, CacheableHttpRequest};
use http::Request;
use http_body_util::Empty;

#[tokio::test]
async fn test_request_path_extractor_some() {
    let request = Request::builder()
        .uri("/users/42/books/24/")
        .body(BufferedBody::Passthrough(Empty::<Bytes>::new()))
        .unwrap();
    let request = CacheableHttpRequest::from_request(request);
    let extractor = NeutralExtractor::new().path("/users/{user_id}/books/{book_id}/");
    let parts = extractor.get(request).await;
    dbg!(parts);
}