Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion examples/cookies/introduction/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ extern crate gotham;
extern crate hyper;
extern crate mime;

use hyper::{Response, StatusCode};
use hyper::header::{Cookie, Headers, SetCookie};
use hyper::{Response, StatusCode};

use gotham::http::response::create_response;
use gotham::state::{FromState, State};
Expand Down
4 changes: 2 additions & 2 deletions examples/example_contribution_template/name/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,11 +25,11 @@ extern crate gotham;
extern crate hyper;
extern crate mime;

use hyper::{Response, StatusCode};
use gotham::http::response::create_response;
use gotham::state::State;
use gotham::router::Router;
use gotham::router::builder::*;
use gotham::state::State;
use hyper::{Response, StatusCode};

/// Create a `Handler` that ...
pub fn well_named_function(state: State) -> (State, Response) {
Expand Down
2 changes: 1 addition & 1 deletion examples/handlers/async_handlers/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ use hyper::{Client, Uri};
use gotham::handler::{HandlerFuture, IntoHandlerError};
use gotham::http::response::create_response;
use gotham::router::Router;
use gotham::router::builder::{build_simple_router, DrawRoutes};
use gotham::router::builder::DefineSingleRoute;
use gotham::router::builder::{build_simple_router, DrawRoutes};
use gotham::state::{FromState, State};

use tokio_core::reactor::Handle;
Expand Down
6 changes: 3 additions & 3 deletions examples/handlers/request_data/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ extern crate gotham;
extern crate hyper;
extern crate mime;

use hyper::{Body, Headers, HttpVersion, Method, Response, StatusCode, Uri};
use futures::{future, Future, Stream};
use hyper::{Body, Headers, HttpVersion, Method, Response, StatusCode, Uri};

use gotham::handler::{HandlerFuture, IntoHandlerError};
use gotham::http::response::create_response;
use gotham::state::{FromState, State};
use gotham::router::Router;
use gotham::router::builder::{build_simple_router, DefineSingleRoute, DrawRoutes};
use gotham::handler::{HandlerFuture, IntoHandlerError};
use gotham::state::{FromState, State};

/// Extract the main elements of the request except for the `Body`
fn print_request_elements(state: &State) {
Expand Down
4 changes: 2 additions & 2 deletions examples/handlers/simple_async_handlers/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,16 @@ extern crate serde_derive;
extern crate tokio_core;
extern crate tokio_timer;

use std::time::Duration;
use futures::{stream, Future, Stream};
use std::time::Duration;

use hyper::StatusCode;

use gotham::handler::{HandlerFuture, IntoHandlerError};
use gotham::http::response::create_response;
use gotham::router::Router;
use gotham::router::builder::{build_simple_router, DrawRoutes};
use gotham::router::builder::DefineSingleRoute;
use gotham::router::builder::{build_simple_router, DrawRoutes};
use gotham::state::{FromState, State};

use tokio_timer::{Timer, TimerError};
Expand Down
4 changes: 2 additions & 2 deletions examples/headers/setting/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ extern crate gotham;
extern crate hyper;
extern crate mime;

use hyper::{Response, StatusCode};
use gotham::http::response::create_response;
use gotham::state::State;
use gotham::router::Router;
use gotham::router::builder::*;
use gotham::state::State;
use hyper::{Response, StatusCode};

// Define a custom header via the standard Hyper provided macro
header! { (GothamHeader, "X-Gotham") => [String] }
Expand Down
2 changes: 1 addition & 1 deletion examples/into_response/introduction/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ extern crate serde_json;

use hyper::{Response, StatusCode};

use gotham::handler::IntoResponse;
use gotham::http::response::create_response;
use gotham::router::Router;
use gotham::router::builder::*;
use gotham::state::State;
use gotham::handler::IntoResponse;

/// A Product
#[derive(Serialize)]
Expand Down
12 changes: 6 additions & 6 deletions examples/middleware/introduction/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,16 +8,16 @@ extern crate hyper;
extern crate mime;

use futures::{future, Future};
use hyper::{Response, StatusCode};
use hyper::header::{Headers, UserAgent};
use gotham::http::response::create_response;
use gotham::handler::HandlerFuture;
use gotham::http::response::create_response;
use gotham::middleware::Middleware;
use gotham::state::{FromState, State};
use gotham::router::Router;
use gotham::router::builder::*;
use gotham::pipeline::new_pipeline;
use gotham::pipeline::single::single_pipeline;
use gotham::router::Router;
use gotham::router::builder::*;
use gotham::state::{FromState, State};
use hyper::header::{Headers, UserAgent};
use hyper::{Response, StatusCode};

/// A simple struct which holds an identifier for the user agent which made the request.
///
Expand Down
2 changes: 1 addition & 1 deletion examples/routing/introduction/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@ extern crate mime;
use hyper::{Response, StatusCode};

use gotham::http::response::create_response;
use gotham::state::State;
use gotham::router::Router;
use gotham::router::builder::*;
use gotham::state::State;

/// Create a `Handler` that is invoked for requests to the path "/"
pub fn say_hello(state: State) -> (State, Response) {
Expand Down
2 changes: 1 addition & 1 deletion examples/sessions/custom_data_type/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ extern crate time;
use hyper::{Response, StatusCode};

use gotham::http::response::create_response;
use gotham::middleware::session::{NewSessionMiddleware, SessionData};
use gotham::pipeline::new_pipeline;
use gotham::pipeline::single::single_pipeline;
use gotham::router::Router;
use gotham::router::builder::*;
use gotham::state::{FromState, State};
use gotham::middleware::session::{NewSessionMiddleware, SessionData};

// A custom type for storing data associated with the user's session.
#[derive(Clone, Deserialize, Serialize, StateData)]
Expand Down
2 changes: 1 addition & 1 deletion examples/sessions/introduction/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@ extern crate mime;
use hyper::{Response, StatusCode};

use gotham::http::response::create_response;
use gotham::middleware::session::{NewSessionMiddleware, SessionData};
use gotham::pipeline::new_pipeline;
use gotham::pipeline::single::single_pipeline;
use gotham::router::Router;
use gotham::router::builder::*;
use gotham::state::{FromState, State};
use gotham::middleware::session::{NewSessionMiddleware, SessionData};

/// Handler function for `GET` requests directed to `/`
///
Expand Down
10 changes: 5 additions & 5 deletions gotham/src/extractor/internal.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,14 +4,14 @@

use std::error::Error;
use std::fmt::{self, Display};
use std::str::FromStr;
use std::marker::PhantomData;
use std::str::FromStr;

use serde::de::{self, Deserialize, DeserializeSeed, Deserializer, EnumAccess, MapAccess,
SeqAccess, VariantAccess, Visitor};

use router::tree::SegmentMapping;
use http::request::query_string::QueryStringMapping;
use router::tree::SegmentMapping;

/// Describes the error cases which can result from deserializing a `ExtractorDeserializer` into a
/// `PathExtractor` provided by the application.
Expand Down Expand Up @@ -859,8 +859,8 @@ mod tests {
}

mod byte_buf {
use std::fmt;
use serde::de::*;
use std::fmt;

pub fn deserialize<'de, D>(de: D) -> Result<Vec<u8>, D::Error>
where
Expand Down Expand Up @@ -922,8 +922,8 @@ mod tests {
}

mod borrowed_bytes {
use std::fmt;
use serde::de::*;
use std::fmt;

pub fn deserialize<'de, D>(de: D) -> Result<&'de [u8], D::Error>
where
Expand Down Expand Up @@ -985,8 +985,8 @@ mod tests {
}

mod borrowed_str {
use std::fmt;
use serde::de::*;
use std::fmt;

pub fn deserialize<'de, D>(de: D) -> Result<&'de str, D::Error>
where
Expand Down
6 changes: 3 additions & 3 deletions gotham/src/extractor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,9 @@
//! the data and store it within the request `State` before the request is dispatched to the
//! `Handler`.

mod query_string;
mod path;
pub(crate) mod internal;
mod path;
mod query_string;

pub use self::query_string::*;
pub use self::path::*;
pub use self::query_string::*;
8 changes: 3 additions & 5 deletions gotham/src/extractor/path.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use serde::{Deserialize, Deserializer};
use hyper::Response;
use serde::{Deserialize, Deserializer};

use state::{State, StateData};
use router::response::extender::StaticResponseExtender;
use state::{State, StateData};

/// Defines a binding for storing the dynamic segments of the `Request` path in `State`. On failure
/// the `StaticResponseExtender` implementation extends the `Response` to indicate why the
Expand Down Expand Up @@ -74,9 +74,7 @@ use router::response::extender::StaticResponseExtender;
/// # let body = response.read_utf8_body().unwrap();
/// # assert_eq!(body, "id = 1551, slug = ten-reasons-serde-is-amazing");
/// # }
pub trait PathExtractor
: for<'de> Deserialize<'de> + StaticResponseExtender + StateData {
}
pub trait PathExtractor: for<'de> Deserialize<'de> + StaticResponseExtender + StateData {}

impl<T> PathExtractor for T
where
Expand Down
9 changes: 5 additions & 4 deletions gotham/src/extractor/query_string.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
use serde::{Deserialize, Deserializer};
use hyper::Response;
use serde::{Deserialize, Deserializer};

use state::{State, StateData};
use router::response::extender::StaticResponseExtender;
use state::{State, StateData};

/// Defines a binding for storing the query parameters from the `Request` URI in `State`. On
/// failure the `StaticResponseExtender` implementation extends the `Response` to indicate why the
Expand Down Expand Up @@ -82,8 +82,9 @@ use router::response::extender::StaticResponseExtender;
/// # let body = response.read_utf8_body().unwrap();
/// # assert_eq!(body, "x = 15, y = B");
/// # }
pub trait QueryStringExtractor
: for<'de> Deserialize<'de> + StaticResponseExtender + StateData {
pub trait QueryStringExtractor:
for<'de> Deserialize<'de> + StaticResponseExtender + StateData
{
}

impl<T> QueryStringExtractor for T
Expand Down
2 changes: 1 addition & 1 deletion gotham/src/handler/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::fmt::{self, Debug, Display, Formatter};
use hyper::{Response, StatusCode};

use handler::IntoResponse;
use state::{request_id, State};
use http::response::create_response;
use state::{request_id, State};

/// Describes an error which occurred during handler execution, and allows the creation of a HTTP
/// `Response`.
Expand Down
2 changes: 1 addition & 1 deletion gotham/src/handler/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
use std::io;
use std::panic::RefUnwindSafe;

use hyper::Response;
use futures::{future, Future};
use hyper::Response;

use state::State;

Expand Down
14 changes: 7 additions & 7 deletions gotham/src/http/header/mod.rs
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
//! Defines HTTP headers which are set by Gotham but not provided by Hyper.

mod x_request_id;
mod x_frame_options;
mod x_xss_protection;
mod x_content_type_options;
mod x_frame_options;
mod x_request_id;
mod x_runtime_microseconds;
mod x_xss_protection;

pub use http::header::x_request_id::XRequestId;
pub use http::header::x_frame_options::XFrameOptions;
pub use http::header::x_xss_protection::XXssProtection;
pub use http::header::x_content_type_options::XContentTypeOptions;
pub use http::header::x_frame_options::XFrameOptions;
pub use http::header::x_request_id::XRequestId;
pub use http::header::x_runtime_microseconds::XRuntimeMicroseconds;
pub use http::header::x_xss_protection::XXssProtection;

use std::str;
use hyper;
use hyper::header::Raw;
use std::str;

/// Reads a single, space delimited, raw string into a Vec.
fn from_one_rws_delimited_raw_str<T: str::FromStr>(raw: &Raw) -> hyper::error::Result<Vec<T>> {
Expand Down
2 changes: 1 addition & 1 deletion gotham/src/http/mod.rs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
//! Helpers for HTTP request handling and response generation

pub mod header;
pub mod request;
pub mod response;
pub mod header;

use std;
use url::percent_encoding::percent_decode;
Expand Down
4 changes: 2 additions & 2 deletions gotham/src/http/response/mod.rs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
//! Helpers for HTTP response generation

use hyper::{Method, Response, StatusCode};
use hyper::header::{ContentLength, ContentType};
use hyper::{Method, Response, StatusCode};
use mime::Mime;

use state::{request_id, FromState, State};
use http::header::{XContentTypeOptions, XFrameOptions, XRequestId, XXssProtection};
use state::{request_id, FromState, State};

type Body = (Vec<u8>, Mime);

Expand Down
6 changes: 3 additions & 3 deletions gotham/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,19 +41,19 @@ extern crate serde_derive;

pub mod extractor;
pub mod handler;
pub mod http;
pub mod middleware;
mod os;
pub mod pipeline;
pub mod http;
pub mod router;
mod service;
pub mod state;
pub mod test;
mod os;

pub use os::current::start_with_num_threads;

use std::net::{SocketAddr, TcpListener, ToSocketAddrs};
use handler::NewHandler;
use std::net::{SocketAddr, TcpListener, ToSocketAddrs};

/// Starts a Gotham application, with the default number of threads (equal to the number of CPUs).
///
Expand Down
4 changes: 2 additions & 2 deletions gotham/src/middleware/session/backend/memory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ use std::sync::{Arc, Mutex, PoisonError, Weak};
use std::time::{Duration, Instant};
use std::{io, thread};

use linked_hash_map::LinkedHashMap;
use futures::future;
use linked_hash_map::LinkedHashMap;

use middleware::session::{SessionError, SessionIdentifier};
use middleware::session::backend::{Backend, NewBackend, SessionFuture};
use middleware::session::{SessionError, SessionIdentifier};

/// Defines the in-process memory based session storage.
///
Expand Down
Loading