Skip to content

Commit cc6bed4

Browse files
committed
reorganize examples and make runnable
1 parent 77dd922 commit cc6bed4

File tree

13 files changed

+48
-22
lines changed

13 files changed

+48
-22
lines changed

README.md

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -71,14 +71,14 @@ fn main() -> Result<(), std::io::Error> {
7171

7272
**More Examples**
7373

74-
- [Hello World](https://github.com/rustasync/tide/tree/master/examples/src/hello.rs)
75-
- [Messages](https://github.com/rustasync/tide/tree/master/examples/src/messages.rs)
76-
- [Body Types](https://github.com/rustasync/tide/tree/master/examples/src/body_types.rs)
77-
- [Multipart Form](https://github.com/rustasync/tide/tree/master/examples/src/multipart_form/mod.rs)
78-
- [Catch All](https://github.com/rustasync/tide/tree/master/examples/src/catch_all.rs)
79-
- [Cookies](https://github.com/rustasync/tide/tree/master/examples/src/cookies.rs)
80-
- [Default Headers](https://github.com/rustasync/tide/tree/master/examples/src/default_headers.rs)
81-
- [GraphQL](https://github.com/rustasync/tide/tree/master/examples/src/graphql.rs)
74+
- [Hello World](https://github.com/rustasync/tide/tree/master/examples/src/bin/hello.rs)
75+
- [Messages](https://github.com/rustasync/tide/tree/master/examples/src/bin/messages.rs)
76+
- [Body Types](https://github.com/rustasync/tide/tree/master/examples/src/bin/body_types.rs)
77+
- [Multipart Form](https://github.com/rustasync/tide/tree/master/examples/src/bin/multipart_form.rs)
78+
- [Catch All](https://github.com/rustasync/tide/tree/master/examples/src/bin/catch_all.rs)
79+
- [Cookies](https://github.com/rustasync/tide/tree/master/examples/src/bin/cookies.rs)
80+
- [Default Headers](https://github.com/rustasync/tide/tree/master/examples/src/bin/default_headers.rs)
81+
- [GraphQL](https://github.com/rustasync/tide/tree/master/examples/src/bin/graphql.rs)
8282

8383
## Resources
8484

examples/README.md

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
# Tide Examples
2+
3+
To run any of the examples:
4+
5+
### From project root
6+
7+
> `cargo run -p examples --bin <example_name>`
8+
9+
#### Some examples
10+
11+
- `cargo run -p examples --bin hello`
12+
- `cargo run -p examples --bin body_types`
13+
14+
### From `examples` directory
15+
16+
> `cargo run --bin <example_name>`
17+
18+
#### Some examples
19+
20+
- `cargo run --bin hello`
21+
- `cargo run --bin body_types`
File renamed without changes.

examples/src/body_types.rs renamed to examples/src/bin/body_types.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(async_await)]
2+
13
use serde::{Deserialize, Serialize};
24
use tide::{
35
error::ResultExt,

examples/src/catch_all.rs renamed to examples/src/bin/catch_all.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(async_await)]
2+
13
use tide::Context;
24

35
async fn echo_path(cx: Context<()>) -> String {

examples/src/cookies.rs renamed to examples/src/bin/cookies.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(async_await)]
2+
13
use cookie::Cookie;
24
use tide::{cookies::ContextExt, middleware::CookiesMiddleware, Context};
35

examples/src/default_headers.rs renamed to examples/src/bin/default_headers.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(async_await)]
2+
13
use tide::middleware::DefaultHeaders;
24

35
pub fn main() {

examples/src/graphql.rs renamed to examples/src/bin/graphql.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(async_await)]
2+
13
// This example uses Juniper to process GraphQL requests. If you're not familiar with Juniper, take
24
// a look at [the Juniper book].
35
//

examples/src/hello.rs renamed to examples/src/bin/hello.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(async_await)]
2+
13
pub fn main() {
24
let mut app = tide::App::new();
35
app.at("/").get(async move |_| "Hello, world!");

examples/src/messages.rs renamed to examples/src/bin/messages.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(async_await)]
2+
13
use http::status::StatusCode;
24
use serde::{Deserialize, Serialize};
35
use std::sync::Mutex;

examples/src/multipart_form/mod.rs renamed to examples/src/bin/multipart_form.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(async_await)]
2+
13
use serde::{Deserialize, Serialize};
24
use std::io::Read;
35
use tide::{forms::ExtractForms, response, App, Context, EndpointResult};
@@ -62,5 +64,5 @@ pub fn run() {
6264
}
6365

6466
// Test with:
65-
// curl -X POST http://localhost:8000/upload_file -H 'content-type: multipart/form-data' -F file=@examples/multipart-form/test.txt
67+
// curl -X POST http://localhost:8000/upload_file -H 'content-type: multipart/form-data' -F file=@data/test.txt
6668
// curl -X POST http://localhost:8000/upload_file -H 'content-type: multipart/form-data' -F key1=v1, -F key2=v2

examples/src/staticfile.rs renamed to examples/src/bin/staticfile.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
#![feature(async_await)]
2+
13
use bytes::Bytes;
24
use futures_fs::FsPool;
35
use futures_util::compat::*;

examples/src/lib.rs

Lines changed: 0 additions & 13 deletions
This file was deleted.

0 commit comments

Comments
 (0)