diff options
-rw-r--r-- | Cargo.lock | 29 | ||||
-rw-r--r-- | Cargo.toml | 1 | ||||
-rw-r--r-- | src/main.rs | 11 | ||||
-rw-r--r-- | static/main.css | 18 |
4 files changed, 57 insertions, 2 deletions
@@ -8,6 +8,7 @@ dependencies = [ "iron-sessionstorage 0.6.6 (registry+https://github.com/rust-lang/crates.io-index)", "log 0.3.7 (registry+https://github.com/rust-lang/crates.io-index)", "router 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "staticfile 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)", ] [[package]] @@ -311,6 +312,15 @@ version = "0.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "mount" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "sequence_trie 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "num_cpus" version = "1.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -424,6 +434,22 @@ version = "0.1.20" source = "registry+https://github.com/rust-lang/crates.io-index" [[package]] +name = "sequence_trie" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" + +[[package]] +name = "staticfile" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +dependencies = [ + "iron 0.5.1 (registry+https://github.com/rust-lang/crates.io-index)", + "mount 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)", + "time 0.1.37 (registry+https://github.com/rust-lang/crates.io-index)", + "url 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)", +] + +[[package]] name = "strsim" version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" @@ -613,6 +639,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum memchr 1.0.1 (registry+https://github.com/rust-lang/crates.io-index)" = "1dbccc0e46f1ea47b9f17e6d67c5a96bd27030519c519c9c91327e31275a47b4" "checksum mime 0.2.4 (registry+https://github.com/rust-lang/crates.io-index)" = "9d69889cdc6336ed56b174514ce876c4c3dc564cc23dd872e7bca589bb2a36c8" "checksum modifier 0.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "41f5c9112cb662acd3b204077e0de5bc66305fa8df65c8019d5adb10e9ab6e58" +"checksum mount 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "32245731923cd096899502fc4c4317cfd09f121e80e73f7f576cf3777a824256" "checksum num_cpus 1.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "ca313f1862c7ec3e0dfe8ace9fa91b1d9cb5c84ace3d00f5ec4216238e93c167" "checksum openssl 0.9.12 (registry+https://github.com/rust-lang/crates.io-index)" = "bb5d1663b73d10c6a3eda53e2e9d0346f822394e7b858d7257718f65f61dfbe2" "checksum openssl-sys 0.9.12 (registry+https://github.com/rust-lang/crates.io-index)" = "3a5886d87d3e2a0d890bf62dc8944f5e3769a405f7e1e9ef6e517e47fd7a0897" @@ -628,6 +655,8 @@ source = "registry+https://github.com/rust-lang/crates.io-index" "checksum rustc-serialize 0.3.24 (registry+https://github.com/rust-lang/crates.io-index)" = "dcf128d1287d2ea9d80910b5f1120d0b8eede3fbf1abe91c40d39ea7d51e6fda" "checksum rustc_version 0.1.7 (registry+https://github.com/rust-lang/crates.io-index)" = "c5f5376ea5e30ce23c03eb77cbe4962b988deead10910c372b226388b594c084" "checksum semver 0.1.20 (registry+https://github.com/rust-lang/crates.io-index)" = "d4f410fedcf71af0345d7607d246e7ad15faaadd49d240ee3b24e5dc21a820ac" +"checksum sequence_trie 0.2.1 (registry+https://github.com/rust-lang/crates.io-index)" = "c915714ca833b1d4d6b8f6a9d72a3ff632fe45b40a8d184ef79c81bec6327eed" +"checksum staticfile 0.4.0 (registry+https://github.com/rust-lang/crates.io-index)" = "31493480e073d52522a94cdf56269dd8eb05f99549effd1826b0271690608878" "checksum strsim 0.6.0 (registry+https://github.com/rust-lang/crates.io-index)" = "b4d15c810519a91cf877e7e36e63fe068815c678181439f2f29e2562147c3694" "checksum term_size 0.3.0 (registry+https://github.com/rust-lang/crates.io-index)" = "e2b6b55df3198cc93372e85dd2ed817f0e38ce8cc0f22eb32391bfad9c4bf209" "checksum thread-id 3.1.0 (registry+https://github.com/rust-lang/crates.io-index)" = "8df7875b676fddfadffd96deea3b1124e5ede707d4884248931077518cf1f773" @@ -10,3 +10,4 @@ log = "*" env_logger = "*" router = "*" horrorshow = "*" +staticfile = "*" diff --git a/src/main.rs b/src/main.rs index a39d08d..70a19af 100644 --- a/src/main.rs +++ b/src/main.rs @@ -10,6 +10,7 @@ extern crate env_logger; extern crate horrorshow; extern crate systemhttp; extern crate iron_sessionstorage; +extern crate staticfile; use iron_sessionstorage::traits::*; use iron_sessionstorage::SessionStorage; @@ -22,6 +23,7 @@ use router::Router; use horrorshow::prelude::*; use horrorshow::Raw; use systemhttp::systemd::unit; +use staticfile::Static; struct Aaa(String); @@ -41,7 +43,10 @@ fn render_message(message: &str, units: &[unit::Unit]) -> String { (html!{ : Raw("<!DOCTYPE html>"); html { - head { title: "Title"; } + head { + title: "Title"; + link(rel="stylesheet", type="text/css", href="static/main.css"); + } body { p { : message @@ -109,7 +114,9 @@ fn main() { let secret = b"secret2".to_vec(); let router = router!( root: get "/" => hello, - name: get "/:name" => hello); + name: get "/:name" => hello, + css: get "/static/main.css" => Static::new(""), + ); let mut chain = Chain::new(router); chain.link_around(SessionStorage::new(SignedCookieBackend::new(secret))); let _server = Iron::new(chain).http(":::8080").unwrap(); diff --git a/static/main.css b/static/main.css new file mode 100644 index 0000000..abfa185 --- /dev/null +++ b/static/main.css @@ -0,0 +1,18 @@ +// CSS file for systemhttpd +h1 { color: red; } +body { + font-family: "Arial"; + font-size: 1em; +} +table, th, td, tr { + padding: 0; + margin: 0; + border-collapse: collapse; +} +th { + text-align: left; + background: lightgray; +} +tr:nth-child(odd) { + background: #eee; +} |