Compare commits
1 commit
main
...
debug_loca
Author | SHA1 | Date | |
---|---|---|---|
72b63aeee1 |
2 changed files with 31 additions and 6 deletions
|
@ -45,8 +45,9 @@ async fn main() {
|
||||||
|
|
||||||
start_db_handler_thread(db_rx, SQLITE_DB_PATH.into(), s_helper_tx.clone());
|
start_db_handler_thread(db_rx, SQLITE_DB_PATH.into(), s_helper_tx.clone());
|
||||||
|
|
||||||
let route = warp::body::content_length_limit(1024 * 32)
|
let route = //warp::body::content_length_limit(1024 * 32)
|
||||||
.and(warp::body::bytes())
|
//.and(warp::body::bytes())
|
||||||
|
warp::body::bytes()
|
||||||
.and_then(move |bytes: bytes::Bytes| {
|
.and_then(move |bytes: bytes::Bytes| {
|
||||||
let db_tx_clone = db_tx_clone.clone();
|
let db_tx_clone = db_tx_clone.clone();
|
||||||
let s_helper_tx_clone = s_helper_tx.clone();
|
let s_helper_tx_clone = s_helper_tx.clone();
|
||||||
|
@ -55,24 +56,48 @@ async fn main() {
|
||||||
if let Ok(body_str) = body_str_result {
|
if let Ok(body_str) = body_str_result {
|
||||||
let json_result = serde_json::from_str(body_str);
|
let json_result = serde_json::from_str(body_str);
|
||||||
if let Ok(json_value) = json_result {
|
if let Ok(json_value) = json_result {
|
||||||
Ok(warp::reply::with_header(
|
let reply = warp::reply::with_header(
|
||||||
json_handlers::handle_json(json_value, db_tx_clone, s_helper_tx_clone)
|
json_handlers::handle_json(json_value, db_tx_clone, s_helper_tx_clone)
|
||||||
.unwrap_or_else(|e| e),
|
.unwrap_or_else(|e| e),
|
||||||
"Content-Type",
|
"Content-Type",
|
||||||
"application/json",
|
"application/json",
|
||||||
|
);
|
||||||
|
let reply = warp::reply::with_header(
|
||||||
|
reply,
|
||||||
|
"Access-Control-Allow-Headers",
|
||||||
|
"*",
|
||||||
|
);
|
||||||
|
Ok::<Box<dyn warp::reply::Reply>, Rejection>(Box::new(
|
||||||
|
warp::reply::with_header(reply, "Access-Control-Allow-Origin", "*"),
|
||||||
))
|
))
|
||||||
} else {
|
} else {
|
||||||
Ok(warp::reply::with_header(
|
let reply = warp::reply::with_header(
|
||||||
String::from("{\"type\": \"invalid_syntax\"}"),
|
String::from("{\"type\": \"invalid_syntax\"}"),
|
||||||
"Content-Type",
|
"Content-Type",
|
||||||
"application/json",
|
"application/json",
|
||||||
|
);
|
||||||
|
let reply = warp::reply::with_header(
|
||||||
|
reply,
|
||||||
|
"Access-Control-Allow-Headers",
|
||||||
|
"*",
|
||||||
|
);
|
||||||
|
Ok::<Box<dyn warp::reply::Reply>, Rejection>(Box::new(
|
||||||
|
warp::reply::with_header(reply, "Access-Control-Allow-Origin", "*"),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Ok::<warp::reply::WithHeader<String>, Rejection>(warp::reply::with_header(
|
let reply = warp::reply::with_header(
|
||||||
String::from("{\"type\": \"invalid_syntax\"}"),
|
String::from("{\"type\": \"invalid_syntax\"}"),
|
||||||
"Content-Type",
|
"Content-Type",
|
||||||
"application/json",
|
"application/json",
|
||||||
|
);
|
||||||
|
let reply = warp::reply::with_header(
|
||||||
|
reply,
|
||||||
|
"Access-Control-Allow-Headers",
|
||||||
|
"*",
|
||||||
|
);
|
||||||
|
Ok::<Box<dyn warp::reply::Reply>, Rejection>(Box::new(
|
||||||
|
warp::reply::with_header(reply, "Access-Control-Allow-Origin", "*"),
|
||||||
))
|
))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,7 +37,7 @@ pub const BACKEND_PHRASE_MAX_LENGTH: usize = 128;
|
||||||
// TODO: Change this to "https://asdm.seodisparate.com/api" when backend is installed
|
// TODO: Change this to "https://asdm.seodisparate.com/api" when backend is installed
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[cfg(debug_assertions)]
|
#[cfg(debug_assertions)]
|
||||||
pub const BACKEND_URL: &str = "http://testlocalhost/api";
|
pub const BACKEND_URL: &str = "http://localhost:1237/";
|
||||||
|
|
||||||
#[allow(dead_code)]
|
#[allow(dead_code)]
|
||||||
#[cfg(not(debug_assertions))]
|
#[cfg(not(debug_assertions))]
|
||||||
|
|
Loading…
Reference in a new issue