13 releases

0.5.0 Dec 10, 2017
0.4.0 Feb 5, 2017
0.3.1 Nov 8, 2016
0.3.0 Jul 27, 2016
0.0.3 Jun 10, 2015

#214 in HTTP server

Download history 1216/week @ 2019-12-02 1181/week @ 2019-12-09 1185/week @ 2019-12-16 779/week @ 2019-12-23 1134/week @ 2019-12-30 1409/week @ 2020-01-06 1169/week @ 2020-01-13 1679/week @ 2020-01-20 1255/week @ 2020-01-27 1332/week @ 2020-02-03 1280/week @ 2020-02-10 1318/week @ 2020-02-17 1453/week @ 2020-02-24 1287/week @ 2020-03-02 1499/week @ 2020-03-09 1616/week @ 2020-03-16

4,985 downloads per month
Used in 24 crates (22 directly)

MIT license

15KB
236 lines

staticfile 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/staticfile/")));
// Serve the source code at /src/
mount.mount("/src/", Static::new(Path::new("target/doc/src/staticfile/lib.rs.html")));

Iron::new(mount).http("127.0.0.1:3000").unwrap();

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

Overview

  • 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 staticfile package to the [dependencies] section of the toml:

staticfile = "*"

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

~3.5MB
~82K SLoC