Skip to content

Commit

Permalink
Tidy up and renaming based on PR feedback.
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbankier committed Sep 11, 2018
1 parent dad88bc commit 2f60822
Show file tree
Hide file tree
Showing 17 changed files with 115 additions and 172 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,8 @@ members = [
"examples/handlers/simple_async_handlers",
# "examples/handlers/async_handlers",

# static_files
"examples/static_files",
# static_assets
"examples/static_assets",

# example_contribution_template
"examples/example_contribution_template/name"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[package]
name = "gotham_examples_static_files_introduction"
name = "gotham_examples_static_assets_introduction"
description = "An example of serving static files with Gotham"
version = "0.0.0"
publish = false
Expand Down
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,25 +1,26 @@
//! An example of serving static files with Gotham.
//! An example of serving static assets with Gotham.

extern crate gotham;

use gotham::handler::static_file::FileOptions;
use gotham::handler::assets::FileOptions;
use gotham::router::builder::{build_simple_router, DefineSingleRoute, DrawRoutes};

pub fn main() {
let path = std::env::args()
.nth(1)
.unwrap_or_else(|| panic!("Need to pass an arg which is the path to serve"));
.skip(1)
.next()
.expect("Need to pass an arg which is the path to serve");
let addr = "127.0.0.1:7878";
println!(
"Listening for requests at http://{} from path {:?}",
addr, path
);

let router = build_simple_router(|route| {
route.get("/").to_file("assets/doc.html");
// You can add a `to_dir` or `to_file` route simply using a
// `String` or `str` as above, or a `Path` or `PathBuf` to accept
// default options.
route.get("/").to_file("assets/doc.html");
// Or you can customize options for comressed file handling, cache
// control headers etc by building a `FileOptions` instance.
route.get("assets/*").to_dir(
Expand Down
5 changes: 3 additions & 2 deletions gotham/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ serde = "1.0"
serde_derive = "1.0"
bincode = "1.0"
mime = "0.3"
mime_guess = "2.0.0-alpha.4"
# Using alpha version of mime_guess until mime crate stabilizes (releases 1.0).
# see https://github.com/hyperium/mime/issues/52
mime_guess = "2.0.0-alpha.6"
futures = "0.1"
tokio = "0.1"
bytes = "0.4"
Expand All @@ -36,7 +38,6 @@ cookie = "0.11"
http = "0.1"
httpdate = "0.3"
failure = "0.1"
failure_derive = "0.1"

[dev-dependencies]
gotham_derive = { path = "../gotham_derive" }
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
//! Defines `AcceptedEncoding` for parsing 'Accept-Encoding' header
//! values in requests, used to determine whether compressed versions
//! of static assets are supported by the client.

use hyper::header::{HeaderMap, ACCEPT_ENCODING};

use std::result;
use std::str::FromStr;

/// An error returned from the `FromStr` implementation
/// for `AcceptedEncoding`
#[derive(Debug, Fail)]
#[derive(Debug)]
pub enum ParseEncodingError {
#[fail(display = "Invalid encoding")]
InvalidEncoding,
}

Expand Down
Loading

0 comments on commit 2f60822

Please sign in to comment.