axum-range

Crates.ioaxum-range
lib.rsaxum-range
version0.4.0
sourcesrc
created_at2023-09-09 07:21:33.946066
updated_at2023-12-29 07:59:08.208632
descriptionHTTP Range responses for axum
homepagehttps://github.com/haileys/axum-range
repositoryhttps://github.com/haileys/axum-range
max_upload_size
id967966
size23,718
Hailey Somerville (haileys)

documentation

https://docs.rs/axum-range

README

axum-range

HTTP range responses for axum.

Documentation.

MIT license.

Example usage

use axum::TypedHeader;
use axum::headers::Range;

use tokio::fs::File;

use axum_range::Ranged;
use axum_range::KnownSize;

async fn file(range: Option<TypedHeader<Range>>) -> Ranged<KnownSize<File>> {
    let file = File::open("archlinux-x86_64.iso").await.unwrap();
    let body = KnownSize::file(file).await.unwrap();
    let range = range.map(|TypedHeader(range)| range);
    Ranged::new(range, body)
}
Commit count: 23

cargo fmt