pub fn with_state(state: State) -> Self {
        let mut server = Self {
            router: Arc::new(Router::new()),
            middleware: Arc::new(vec![]),
            state: Arc::new(state),
        };
        server.middleware(cookies::CookiesMiddleware::new());
        server.middleware(log::LogMiddleware::new());
        server
    }
/// Create a new Tide server with shared application scoped state.
///
/// Application scoped state is useful for storing items
///
/// # Examples
///
/// ```no_run
/// # use async_std::task::block_on;
/// # fn main() -> Result<(), std::io::Error> { block_on(async {
/// #
/// use tide::Request;
///
/// /// The shared application state.
/// struct State {
///     name: String,
/// }
///
/// // Define a new instance of the state.
/// let state = State {
///     name: "Nori".to_string()
/// };
///
/// // Initialize the application with state.
/// let mut app = tide::with_state(state);
/// app.at("/").get(|req: Request<State>| async move {
///     Ok(format!("Hello, {}!", &req.state().name))
/// });
/// app.listen("127.0.0.1:8080").await?;
/// #
/// # Ok(()) }) }
/// ```
Create a new Tide server with shared application scoped state.
Application scoped state is useful for storing items
Create a new Tide server with shared application scoped state . Application scoped state is useful for storing items
pub fn with_state(state: State) -> Self {
        let mut server = Self {
            router: Arc::new(Router::new()),
            middleware: Arc::new(vec![]),
            state: Arc::new(state),
        };
        server.middleware(cookies::CookiesMiddleware::new());
        server.middleware(log::LogMiddleware::new());
        server
    }
pub fn with_state ( state : State ) -> Self { let mut server = Self { router : Arc :: new ( Router :: new ( ) ) , middleware : Arc :: new ( vec ! [ ] ) , state : Arc :: new ( state ) , } ; server . middleware ( cookies :: CookiesMiddleware :: new ( ) ) ; server . middleware ( log :: LogMiddleware :: new ( ) ) ; server }
Create a new Tide server with shared application scoped state.
Create a new Tide server with shared application scoped state .
state
State
state
State
examples
None
use async_std::task::block_on;
None
fn main() -> result<(), std::io::error> { block_on(async {
use tide::Request.

The shared application state.
struct State {
name: String,
}

Define a new instance of the state.
let state = State {
name: "Nori".to_string()
}.

Initialize the application with state.
use tide :: Request . The shared application state . struct State { name : String } Define a new instance of the state . let state = State { name : " Nori " . to_string () } . Initialize the application with state .
ok(()) }) }
None