Formatted files
This commit is contained in:
@@ -1,7 +1,7 @@
|
||||
use crate::types::*;
|
||||
use crate::AppState;
|
||||
use crate::types::*;
|
||||
use actix_web::web::Data;
|
||||
use actix_web::{get, web, HttpResponse, Responder};
|
||||
use actix_web::{HttpResponse, Responder, get, web};
|
||||
use serde_json::to_string;
|
||||
use sqlx::query_as;
|
||||
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
use crate::types::*;
|
||||
use crate::AppState;
|
||||
use crate::types::*;
|
||||
use actix_web::web::Data;
|
||||
use actix_web::{get, web, HttpResponse, Responder};
|
||||
use actix_web::{HttpResponse, Responder, get, web};
|
||||
use serde_json::to_string;
|
||||
use sqlx::query_as;
|
||||
|
||||
|
||||
11
src/main.rs
11
src/main.rs
@@ -1,4 +1,5 @@
|
||||
mod cases;
|
||||
mod inventories;
|
||||
mod items;
|
||||
mod types;
|
||||
mod users;
|
||||
@@ -10,7 +11,7 @@ use users::*;
|
||||
use utils::*;
|
||||
|
||||
use actix_web::web::Data;
|
||||
use actix_web::{middleware::DefaultHeaders, App, HttpServer};
|
||||
use actix_web::{App, HttpServer, middleware::DefaultHeaders};
|
||||
use sqlx::sqlite::SqlitePool;
|
||||
|
||||
#[derive(Clone)]
|
||||
@@ -32,10 +33,14 @@ async fn main() -> std::io::Result<()> {
|
||||
});
|
||||
HttpServer::new(move || {
|
||||
App::new()
|
||||
.wrap(DefaultHeaders::new().add((
|
||||
.wrap(
|
||||
DefaultHeaders::new()
|
||||
.add((
|
||||
"Access-Control-Allow-Origin",
|
||||
app_state.allow_origins.join(","),
|
||||
)).add(("Access-Control-Allow-Credentials", "true")))
|
||||
))
|
||||
.add(("Access-Control-Allow-Credentials", "true")),
|
||||
)
|
||||
.service(login)
|
||||
.service(register)
|
||||
.service(logout)
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
use crate::AppState;
|
||||
use actix_web::web::Data;
|
||||
use actix_web::{options, HttpResponse, Responder};
|
||||
use actix_web::{HttpResponse, Responder, options};
|
||||
|
||||
// This is needed for the web client.
|
||||
// This returns the same options for every path of the api
|
||||
@@ -12,7 +12,10 @@ async fn options(app_state: Data<AppState>) -> impl Responder {
|
||||
app_state.allow_origins.join(","),
|
||||
))
|
||||
.append_header(("Access-Control-Allow-Methods", "GET, OPTIONS"))
|
||||
.append_header(("Access-Control-Allow-Headers", "Content-Type, Authorization"))
|
||||
.append_header((
|
||||
"Access-Control-Allow-Headers",
|
||||
"Content-Type, Authorization",
|
||||
))
|
||||
.append_header(("Access-Control-Allow-Credentials", "true"))
|
||||
.finish()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user