Crates.io | axum-range |
lib.rs | axum-range |
version | 0.4.0 |
source | src |
created_at | 2023-09-09 07:21:33.946066 |
updated_at | 2023-12-29 07:59:08.208632 |
description | HTTP Range responses for axum |
homepage | https://github.com/haileys/axum-range |
repository | https://github.com/haileys/axum-range |
max_upload_size | |
id | 967966 |
size | 23,718 |
HTTP range responses for axum
.
MIT license.
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)
}