# staticdir Serving directory contents for [Iron](https://github.com/iron/iron) web-framework. Documentation can be found [here](http://franza.github.io/staticdir/index.html). ## Purpose Provides the list of files and directories in a mounted folder. To respond with files use [staticfile](https://github.com/iron/staticfile) along with this one. See examples. ## Example Start web server at `http://localhost:3000` and mount current directory. List of directory contents will be available as JSON. ```rust extern crate staticdir; extern crate iron; use iron::prelude::*; use staticdir::{ StaticDir, AsJson }; fn main() { Iron::new(StaticDir::new(".", AsJson)).http("localhost:3000").unwrap(); } ``` This code will return you ```JSON [ { "file_type": "File", "file_name": ".gitignore", "size": 7, "creation_time": null, "last_modification_time": 1451939290, "last_access_time": 1451939309 }, { "file_type": "File", "file_name": "Cargo.toml", "size": 196, "creation_time": null, "last_modification_time": 1451939547, "last_access_time": 1451939547 }, { "file_type": "Dir", "file_name": "src", "size": 4096, "creation_time": null, "last_modification_time": 1451939462, "last_access_time": 1451939462 } ] ``` ## Customize behavior You can customize the response using `ResponseStrategy` trait. Suppose you need an HTML response instead of JSON: ```rust extern crate staticdir; extern crate iron; use iron::prelude::*; use iron::status::Status; use staticdir::{ StaticDir, ResponseStrategy }; use std::fs::ReadDir; use iron::mime::Mime; struct AsHtml; fn build_html(dir: ReadDir) -> String { let mut html = String::new(); for entry in dir { let entry = entry.unwrap(); html = format!("{}