1 unstable release
0.1.0 | Oct 9, 2021 |
---|
#1371 in HTTP server
8KB
53 lines
trillium-send-file
Send file connection extension for trillium.rs.
Getting Started
[dependencies]
trillium = "0.2.0"
trillium-smol = "0.2.0"
trillium-send-file = { version = "0.1.0", features = ["smol"] }
Use features = ["async-std"]
for async-std runtime.
Example
src/main.rs
use trillium::Conn;
use trillium_send_file::SendFileConnExt;
fn main() {
trillium_smol::run(|conn: Conn| async move {
conn.send_file("/tmp/file.txt".into()).await
});
}
lib.rs
:
Send a static file from the file system along with appropriate mime type.
[dependencies]
trillium = "0.2.0"
trillium-smol = "0.2.0"
trillium-send-file = { version = "0.1.0", features = ["smol"] }
Use features = ["async-std"]
for async-std runtime.
use trillium::Conn;
use trillium_send_file::SendFileConnExt;
fn main() {
trillium_smol::run(|conn: Conn| async move {
conn.send_file("/tmp/file.txt".into()).await
});
}
Dependencies
~6–20MB
~295K SLoC