Skip to content

Commit

Permalink
Merge pull request #219 from prasannavl/2019_05_tide_isolate_core
Browse files Browse the repository at this point in the history
Precursor: Tide core isolation revamp
  • Loading branch information
prasannavl authored May 15, 2019
2 parents 4a53890 + d67ec8f commit a50668f
Show file tree
Hide file tree
Showing 30 changed files with 125 additions and 91 deletions.
65 changes: 4 additions & 61 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,65 +1,8 @@
[package]
authors = [
"Aaron Turon <aturon@mozilla.com>",
"Yoshua Wuyts <yoshuawuyts@gmail.com>",
[workspace]
members = [
"tide",
"examples",
]
description = "WIP modular web framework"
documentation = "https://docs.rs/tide"
keywords = ["tide", "http", "web", "framework", "async"]
categories = [
"network-programming",
"asynchronous",
"web-programming::http-server"
]
edition = "2018"
license = "MIT OR Apache-2.0"
name = "tide"
readme = "README.md"
repository = "https://github.com/rustasync/tide"
version = "0.2.0"

[dependencies]
cookie = { version = "0.12", features = ["percent-encode"] }
futures-preview = "0.3.0-alpha.16"
fnv = "1.0.6"
http = "0.1"
http-service = "0.2.0"
pin-utils = "0.1.0-alpha.4"
route-recognizer = "0.1.12"
serde = "1.0.91"
serde_derive = "1.0.91"
serde_json = "1.0.39"
slog = "2.4.1"
slog-async = "2.3.0"
slog-term = "2.4.0"
typemap = "0.3.3"
serde_urlencoded = "0.5.5"

[dependencies.http-service-hyper]
optional = true
version = "0.2.0"

[dependencies.multipart]
default-features = false
features = ["server"]
version = "0.16.1"

[features]
default = ["hyper"]
hyper = ["http-service-hyper"]

[dev-dependencies]
basic-cookies = "0.1.3"
bytes = "0.4.12"
futures-fs = "0.0.5"
futures-util-preview = { version = "0.3.0-alpha.16", features = ["compat"] }
http-service-mock = "0.2.0"
juniper = "0.11.1"
mime = "0.3.13"
mime_guess = "2.0.0-alpha.6"
percent-encoding = "1.0.1"
serde = { version = "1.0.90", features = ["derive"] }
structopt = "0.2.15"

[patch.crates-io]
http-service = { git = "https://github.com/rustasync/http-service", branch = "master" }
Expand Down
46 changes: 46 additions & 0 deletions examples/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
[package]
authors = [
"Tide Developers",
]
description = "Tide web server examples"
documentation = "https://docs.rs/tide"
edition = "2018"
license = "MIT OR Apache-2.0"
name = "examples"
readme = "README.md"
repository = "https://github.com/rustasync/tide"
version = "0.1.0"
publish = false

[dependencies]
tide = { path = "../tide" }
cookie = { version = "0.12", features = ["percent-encode"] }
futures-preview = "0.3.0-alpha.16"
fnv = "1.0.6"
http = "0.1"
http-service = "0.2.0"
pin-utils = "0.1.0-alpha.4"
route-recognizer = "0.1.12"
serde_json = "1.0.39"
slog = "2.4.1"
slog-async = "2.3.0"
slog-term = "2.4.0"
typemap = "0.3.3"
serde_urlencoded = "0.5.5"
basic-cookies = "0.1.3"
bytes = "0.4.12"
futures-fs = "0.0.5"
futures-util-preview = { version = "0.3.0-alpha.16", features = ["compat"] }
http-service-mock = "0.2.0"
juniper = "0.11.1"
mime = "0.3.13"
mime_guess = "2.0.0-alpha.6"
percent-encoding = "1.0.1"
serde = { version = "1.0.91", features = ["derive"] }
structopt = "0.2.15"

[dependencies.multipart]
default-features = false
features = ["server"]
version = "0.16.1"

4 changes: 1 addition & 3 deletions examples/body_types.rs → examples/src/body_types.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(async_await)]

use serde::{Deserialize, Serialize};
use tide::{
error::ResultExt,
Expand Down Expand Up @@ -41,7 +39,7 @@ async fn echo_form(mut cx: Context<()>) -> EndpointResult {
Ok(forms::form(msg))
}

fn main() {
pub fn main() {
let mut app = App::new();

app.at("/echo/string").post(echo_string);
Expand Down
4 changes: 1 addition & 3 deletions examples/catch_all.rs → examples/src/catch_all.rs
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
#![feature(async_await)]

use tide::Context;

async fn echo_path(cx: Context<()>) -> String {
let path: String = cx.param("path").unwrap();
format!("Your path is: {}", path)
}

fn main() {
pub fn main() {
let mut app = tide::App::new();
app.at("/echo_path/*path").get(echo_path);
app.serve("127.0.0.1:8000").unwrap();
Expand Down
5 changes: 1 addition & 4 deletions examples/cookies.rs → examples/src/cookies.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
#![feature(async_await)]

use cookie::Cookie;
use tide::{cookies::ContextExt, middleware::CookiesMiddleware, Context};

/// Tide will use the the `Cookies`'s `Extract` implementation to build this parameter.
///
async fn retrieve_cookie(mut cx: Context<()>) -> String {
format!("hello cookies: {:?}", cx.get_cookie("hello").unwrap())
}
Expand All @@ -19,7 +16,7 @@ async fn remove_cookie(mut cx: Context<()>) {
cx.remove_cookie(Cookie::named("hello")).unwrap();
}

fn main() {
pub fn main() {
let mut app = tide::App::new();
app.middleware(CookiesMiddleware::new());

Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
#![feature(async_await)]

use tide::middleware::DefaultHeaders;

fn main() {
pub fn main() {
let mut app = tide::App::new();

app.middleware(
Expand Down
5 changes: 1 addition & 4 deletions examples/graphql.rs → examples/src/graphql.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,6 @@
// a look at [the Juniper book].
//
// [the Juniper book]: https://graphql-rust.github.io/

#![feature(async_await)]

use http::status::StatusCode;
use juniper::graphql_object;
use std::sync::{atomic, Arc};
Expand Down Expand Up @@ -59,7 +56,7 @@ async fn handle_graphql(mut cx: Context<Data>) -> EndpointResult {
Ok(resp)
}

fn main() {
pub fn main() {
let mut app = App::with_state(Data::default());
app.at("/graphql").post(handle_graphql);
app.serve("127.0.0.1:8000").unwrap();
Expand Down
4 changes: 1 addition & 3 deletions examples/hello.rs → examples/src/hello.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
#![feature(async_await)]

fn main() {
pub fn main() {
let mut app = tide::App::new();
app.at("/").get(async move |_| "Hello, world!");
app.serve("127.0.0.1:8000").unwrap();
Expand Down
13 changes: 13 additions & 0 deletions examples/src/lib.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#![feature(async_await)]
#![warn(clippy::all)]
#![allow(dead_code)]

mod body_types;
mod catch_all;
mod cookies;
mod default_headers;
mod graphql;
mod hello;
mod messages;
mod multipart_form;
mod staticfile;
4 changes: 1 addition & 3 deletions examples/messages.rs → examples/src/messages.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(async_await)]

use http::status::StatusCode;
use serde::{Deserialize, Serialize};
use std::sync::Mutex;
Expand Down Expand Up @@ -66,7 +64,7 @@ async fn get_message(cx: Context<Database>) -> EndpointResult {
}
}

fn main() {
pub fn main() {
let mut app = App::with_state(Database::default());
app.at("/message").post(new_message);
app.at("/message/:id").get(get_message).post(set_message);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(async_await)]

use serde::{Deserialize, Serialize};
use std::io::Read;
use tide::{forms::ExtractForms, response, App, Context, EndpointResult};
Expand Down Expand Up @@ -57,7 +55,7 @@ async fn upload_file(mut cx: Context<()>) -> EndpointResult {
Ok(response::json(message))
}

fn main() {
pub fn run() {
let mut app = App::new();
app.at("/upload_file").post(upload_file);
app.serve("127.0.0.1:8000").unwrap();
Expand Down
File renamed without changes.
6 changes: 2 additions & 4 deletions examples/staticfile.rs → examples/src/staticfile.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#![feature(async_await)]

use bytes::Bytes;
use futures_fs::FsPool;
use futures_util::compat::*;
Expand Down Expand Up @@ -44,7 +42,7 @@ impl StaticFile {
// Check if the path exists and handle if it's a directory containing `index.html`
if meta.is_some() && meta.as_ref().map(|m| !m.is_file()).unwrap_or(false) {
// Redirect if path is a dir and URL doesn't end with "/"
if !actual_path.ends_with("/") {
if !actual_path.ends_with('/') {
return Ok(response
.status(StatusCode::MOVED_PERMANENTLY)
.header(header::LOCATION, String::from(actual_path) + "/")
Expand Down Expand Up @@ -121,7 +119,7 @@ async fn handle_path(ctx: Context<StaticFile>) -> EndpointResult {
})
}

fn main() {
pub fn main() {
let mut app = App::with_state(StaticFile::new("./"));
app.at("/*").get(handle_path);
app.serve("127.0.0.1:8000").unwrap();
Expand Down
52 changes: 52 additions & 0 deletions tide/Cargo.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
[package]
authors = [
"Aaron Turon <aturon@mozilla.com>",
"Yoshua Wuyts <yoshuawuyts@gmail.com>",
]
description = "WIP modular web framework"
documentation = "https://docs.rs/tide"
keywords = ["tide", "http", "web", "framework", "async"]
categories = [
"network-programming",
"asynchronous",
"web-programming::http-server"
]
edition = "2018"
license = "MIT OR Apache-2.0"
name = "tide"
readme = "README.md"
repository = "https://github.com/rustasync/tide"
version = "0.2.0"

[dependencies]
cookie = { version = "0.12", features = ["percent-encode"] }
futures-preview = "0.3.0-alpha.16"
fnv = "1.0.6"
http = "0.1"
http-service = "0.2.0"
pin-utils = "0.1.0-alpha.4"
route-recognizer = "0.1.12"
serde = "1.0.91"
serde_derive = "1.0.91"
serde_json = "1.0.39"
slog = "2.4.1"
slog-async = "2.3.0"
slog-term = "2.4.0"
typemap = "0.3.3"
serde_urlencoded = "0.5.5"

[dependencies.http-service-hyper]
optional = true
version = "0.2.0"

[dependencies.multipart]
default-features = false
features = ["server"]
version = "0.16.1"

[features]
default = ["hyper"]
hyper = ["http-service-hyper"]

[dev-dependencies]
http-service-mock = "0.2.0"
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.

0 comments on commit a50668f

Please sign in to comment.