Crates.io | tide-naive-static-files |
lib.rs | tide-naive-static-files |
version | 2.2.0 |
source | src |
created_at | 2019-11-30 00:40:20.315891 |
updated_at | 2020-02-28 19:50:39.184906 |
description | A simple static file serving component for Rust's Tide web framework. |
homepage | https://github.com/eignnx/tide-naive-static-files |
repository | https://github.com/eignnx/tide-naive-static-files |
max_upload_size | |
id | 185460 |
size | 75,650 |
A simple static file serving component for Rust's Tide web framework.
This code is based heavily on this archived example.
This crate is not officially associated with the tide
project, it's more of an interim solution while tide
is still in a state of (relative) flux.
Mistakes were made when initially selecting version numbers for this crate. In the Rust ecosystem, a 1.0.0 release generally means the crate is fit for production. This crate makes no such claim. It would be best to "divide by ten" when looking at the crate's version number (i.e. 2.0.1 should be thought of as 0.2.0.1).
To use the library:
get
endpoint with the StaticFilesEndpoint
making sure the root
represents the path from where you run the server to the root of your assetsuse async_std::task;
use tide_naive_static_files::StaticFilesEndpoint;
struct AppState {}
fn main() {
let state = AppState {};
let mut app = tide::with_state(state);
app.at("/static") // 1.
.strip_prefix() // 2
.get(StaticFilesEndpoint {
root: "./examples/".into(), // 3.
});
task::block_on(async move { app.listen("127.0.0.1:8000").await.unwrap() });
}
If you're interested in contributing to the project, please see our CONTRIBUTING.md file!