Skip to content

Commit 6b6262f

Browse files
committed
update for axum07
1 parent 1dcd0b2 commit 6b6262f

File tree

7 files changed

+11
-16
lines changed

7 files changed

+11
-16
lines changed

axum/starwars/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ async-graphql = { path = "../../.." }
88
async-graphql-axum = { path = "../../../integrations/axum" }
99
tokio = { version = "1.8", features = ["macros", "rt-multi-thread"] }
1010
starwars = { path = "../../models/starwars" }
11-
hyper = "0.14"
1211
axum = { version = "0.7.0" }

axum/subscription/Cargo.toml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[package]
2-
name = "subscription"
2+
name = "axum-subscription"
33
version = "0.1.0"
44
edition = "2021"
55

@@ -8,5 +8,4 @@ async-graphql = { path = "../../.." }
88
async-graphql-axum = { path = "../../../integrations/axum" }
99
tokio = { version = "1.8", features = ["macros", "rt-multi-thread"] }
1010
books = { path = "../../models/books" }
11-
hyper = "0.14"
1211
axum = { version = "0.7.0", features = ["ws"] }

axum/subscription/src/main.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,9 +3,10 @@ use async_graphql_axum::{GraphQL, GraphQLSubscription};
33
use axum::{
44
response::{self, IntoResponse},
55
routing::get,
6-
Router, Server,
6+
Router,
77
};
88
use books::{MutationRoot, QueryRoot, Storage, SubscriptionRoot};
9+
use tokio::net::TcpListener;
910

1011
async fn graphiql() -> impl IntoResponse {
1112
response::Html(
@@ -31,8 +32,7 @@ async fn main() {
3132

3233
println!("GraphiQL IDE: http://localhost:8000");
3334

34-
Server::bind(&"127.0.0.1:8000".parse().unwrap())
35-
.serve(app.into_make_service())
35+
axum::serve(TcpListener::bind("127.0.0.1:8000").await.unwrap(), app)
3636
.await
3737
.unwrap();
3838
}

axum/token-from-header/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,4 @@ async-graphql = { path = "../../.." }
88
async-graphql-axum = { path = "../../../integrations/axum" }
99
tokio = { version = "1.8", features = ["macros", "rt-multi-thread"] }
1010
token = { path = "../../models/token" }
11-
hyper = "0.14"
1211
axum = { version = "0.7.0", features = ["ws"] }

axum/token-from-header/src/main.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,8 +61,7 @@ async fn main() {
6161

6262
println!("Playground: http://localhost:8000");
6363

64-
Server::bind(&"127.0.0.1:8000".parse().unwrap())
65-
.serve(app.into_make_service())
64+
axum::serve(TcpListener::bind("127.0.0.1:8000").await.unwrap(), app)
6665
.await
6766
.unwrap();
6867
}

axum/upload/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,4 @@ async-graphql-axum = { path = "../../../integrations/axum" }
1010
axum = "0.7.0"
1111
files = { path = "../../models/files" }
1212
tokio = { version = "1.8", features = ["macros", "rt-multi-thread"] }
13-
hyper = "0.14"
1413
tower-http = { version = "0.5.0", features = ["cors"] }

axum/upload/src/main.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
use async_graphql::{http::GraphiQLSource, EmptySubscription, Schema};
22
use async_graphql_axum::GraphQL;
33
use axum::{
4+
http::Method,
45
response::{Html, IntoResponse},
56
routing::get,
67
Router,
78
};
89
use files::{MutationRoot, QueryRoot, Storage};
9-
use hyper::{Method, Server};
10-
use tower_http::cors::{CorsLayer, Origin};
10+
use tokio::net::TcpListener;
11+
use tower_http::cors::{AllowOrigin, CorsLayer};
1112

1213
async fn graphiql() -> impl IntoResponse {
1314
Html(GraphiQLSource::build().endpoint("/").finish())
@@ -25,12 +26,11 @@ async fn main() {
2526
.route("/", get(graphiql).post_service(GraphQL::new(schema)))
2627
.layer(
2728
CorsLayer::new()
28-
.allow_origin(Origin::predicate(|_, _| true))
29-
.allow_methods(vec![Method::GET, Method::POST]),
29+
.allow_origin(AllowOrigin::predicate(|_, _| true))
30+
.allow_methods([Method::GET, Method::POST]),
3031
);
3132

32-
Server::bind(&"127.0.0.1:8000".parse().unwrap())
33-
.serve(app.into_make_service())
33+
axum::serve(TcpListener::bind("127.0.0.1:8000").await.unwrap(), app)
3434
.await
3535
.unwrap();
3636
}

0 commit comments

Comments
 (0)