noise-server/src/net.rs

21 lines
627 B
Rust
Raw Normal View History

2021-10-23 17:39:05 +02:00
use std::net::IpAddr;
use sqlx::SqlitePool;
2021-10-23 17:39:05 +02:00
use warp::Filter;
use crate::graphql::{
Context,
schema,
};
2021-10-23 17:39:05 +02:00
pub async fn web(ip_address: IpAddr, port: u16, db: SqlitePool) {
std::env::set_var("RUST_LOG", "warp_async");
let state = warp::any().map(move || Context { db: db.clone() });
let graphql_filter = juniper_warp::make_graphql_filter(schema(), state.boxed());
warp::serve(
warp::get()
.and(warp::path("graphiql"))
.and(juniper_warp::graphiql_filter("/graphql", None))
.or(warp::path("graphql").and(graphql_filter)),
2021-10-23 17:39:05 +02:00
).run((ip_address, port)).await;
}