Update
This commit is contained in:
parent
027aad58f9
commit
7f3cf3b2b5
11 changed files with 55 additions and 710 deletions
|
@ -6,21 +6,7 @@ use tikv_jemallocator::Jemalloc;
|
|||
static GLOBAL: Jemalloc = Jemalloc;
|
||||
|
||||
use actix_cors::Cors;
|
||||
use actix_web::{
|
||||
http::header,
|
||||
middleware,
|
||||
web::{self, Data},
|
||||
App, Error, HttpResponse, HttpServer,
|
||||
};
|
||||
use juniper_actix::graphql_handler;
|
||||
|
||||
async fn graphql_route(
|
||||
req: actix_web::HttpRequest,
|
||||
payload: actix_web::web::Payload,
|
||||
schema: web::Data<backend::graphql::Schema>,
|
||||
) -> Result<HttpResponse, Error> {
|
||||
graphql_handler(&schema, &backend::graphql::Context, req, payload).await
|
||||
}
|
||||
use actix_web::{http::header, middleware, App, HttpServer};
|
||||
|
||||
#[actix_web::main]
|
||||
async fn main() -> std::io::Result<()> {
|
||||
|
@ -29,23 +15,17 @@ async fn main() -> std::io::Result<()> {
|
|||
|
||||
let server = HttpServer::new(move || {
|
||||
App::new()
|
||||
.app_data(Data::new(backend::graphql::schema()))
|
||||
.wrap(
|
||||
Cors::default()
|
||||
.allow_any_origin()
|
||||
.allowed_methods(vec!["POST", "GET"])
|
||||
.allowed_headers(vec![header::AUTHORIZATION, header::ACCEPT])
|
||||
.allowed_header(header::ACCEPT)
|
||||
.allowed_header(header::CONTENT_TYPE)
|
||||
.supports_credentials()
|
||||
.max_age(3600),
|
||||
)
|
||||
.wrap(middleware::Compress::default())
|
||||
.wrap(middleware::Logger::default())
|
||||
.service(
|
||||
web::resource("/graphql")
|
||||
.route(web::post().to(graphql_route))
|
||||
.route(web::get().to(graphql_route)),
|
||||
)
|
||||
});
|
||||
server.bind("0.0.0.0:80").unwrap().run().await
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue