#static-file #error #path #iron

nightly static

Static file serving for Iron

4 releases

Uses old Rust 2015

0.0.4 Mar 25, 2015
0.0.3 Mar 12, 2015
0.0.2 Feb 17, 2015
0.0.1 Dec 8, 2014

#456 in Caching

Download history 7/week @ 2023-10-18 8/week @ 2023-10-25 11/week @ 2023-11-01 8/week @ 2023-11-08 9/week @ 2023-11-15 10/week @ 2023-11-22 17/week @ 2023-11-29 14/week @ 2023-12-06 10/week @ 2023-12-13 11/week @ 2023-12-20 8/week @ 2023-12-27 7/week @ 2024-01-03 6/week @ 2024-01-10 24/week @ 2024-01-17 12/week @ 2024-01-24 8/week @ 2024-01-31

51 downloads per month

MIT license

10KB
148 lines

static Build Status

Static file-serving handler for the Iron web framework.

Example

This example uses the mounting handler to serve files from several directories.

let mut mount = Mount::new();

// Serve the shared JS/CSS at /
mount.mount("/", Static::new(Path::new("target/doc/")));
// Serve the static file docs at /doc/
mount.mount("/doc/", Static::new(Path::new("target/doc/static/")));
// Serve the source code at /src/
mount.mount("/src/", Static::new(Path::new("target/doc/src/static/lib.rs.html")));

Iron::new(mount).listen(Ipv4Addr(127, 0, 0, 1), 3000).unwrap();

Note that static is a reserved keyword, so the crate will need to be imported as extern crate "static" as static_file;.

See examples/doc_server.rs for a complete example that you can compile.

Overview

static is a part of Iron's core bundle.

  • Serve static files from a given path.

It works well in combination with the mounting handler.

Installation

If you're using a Cargo.toml to manage dependencies, just add the static package to the toml:

[dependencies.static]

git = "https://github.com/iron/static.git"

Otherwise, cargo build, and the rlib will be in your target directory.

Documentation

Along with the online documentation, you can build a local copy with cargo doc.

Get Help

One of us (@reem, @zzmp, @theptrk, @mcreinhard) is usually on #iron on the mozilla irc. Come say hi and ask any questions you might have. We are also usually on #rust and #rust-webdev.

Dependencies

~5.5MB
~129K SLoC