refactor how endpoints are grouped

This commit is contained in:
Brandon Thomas committed 2021-05-20 23:42:54 -04:00
1 parent f4437cfe0a
commit 235d86ca2b
11 files changed
+27 -15

No files matched your search

+1 -1
View File
@@ -4,7 +4,7 @@ import requests
import re
login_url = 'http://localhost:12345/login'
upload_url = 'http://localhost:12345/upload_tts'
upload_url = 'http://localhost:12345/tts/upload'
payload = {
'username_or_email': 'echelon',
-2
View File
@@ -1,2 +0,0 @@
pub mod infer_tts;
pub mod infer_w2l;
-2
View File
@@ -1,2 +0,0 @@
pub mod upload_tts_model;
pub mod upload_w2l_template;
+3 -3
View File
@@ -1,6 +1,6 @@
pub mod default_route_404;
pub mod enqueue_inference;
pub mod enqueue_uploads;
pub mod misc;
pub mod root_index;
pub mod users;
pub mod tts;
pub mod users;
pub mod w2l;
+2
View File
@@ -0,0 +1,2 @@
pub mod enqueue_infer_tts;
pub mod enqueue_upload_tts_model;
@@ -103,6 +103,7 @@ pub async fn infer_w2l_handler(
return Err(InferW2lError::BadInput("w2l token is required".to_string()));
},
Some(t) => {
// TODO: CHECK DATABASE!
t.to_string()
},
};
@@ -112,7 +113,10 @@ pub async fn infer_w2l_handler(
// TODO: Allow audio uploads.
return Err(InferW2lError::BadInput("tts token is required".to_string()));
},
Some(t) => t.to_string(),
Some(t) => {
// TODO: CHECK DATABASE!
t.to_string()
},
};
let ip_address = get_request_ip(&http_request);
+2
View File
@@ -0,0 +1,2 @@
pub mod enqueue_infer_w2l;
pub mod enqueue_upload_w2l_template;
+14 -6
View File
@@ -19,14 +19,14 @@ use actix_http::http;
use actix_web::middleware::{Logger, DefaultHeaders};
use actix_web::{HttpServer, web, HttpResponse, App};
use crate::endpoints::default_route_404::default_route_404;
use crate::endpoints::enqueue_uploads::upload_tts_model::upload_tts_model_handler;
use crate::endpoints::enqueue_uploads::upload_w2l_template::upload_w2l_template_handler;
use crate::endpoints::misc::enable_alpha::enable_alpha;
use crate::endpoints::root_index::get_root_index;
use crate::endpoints::users::create_account::create_account_handler;
use crate::endpoints::users::login::login_handler;
use crate::endpoints::users::logout::logout_handler;
use crate::endpoints::users::session_info::session_info_handler;
use crate::endpoints::w2l::enqueue_infer_w2l::infer_w2l_handler;
use crate::endpoints::w2l::enqueue_upload_w2l_template::upload_w2l_template_handler;
use crate::server_state::{ServerState, EnvConfig};
use crate::util::cookies::CookieManager;
use crate::util::session_checker::SessionChecker;
@@ -34,7 +34,7 @@ use log::{info};
use sqlx::MySqlPool;
use sqlx::mysql::MySqlPoolOptions;
use std::sync::Arc;
use crate::endpoints::enqueue_inference::infer_w2l::infer_w2l_handler;
use crate::endpoints::tts::enqueue_upload_tts_model::upload_tts_model_handler;
const DEFAULT_BIND_ADDRESS : &'static str = "0.0.0.0:12345";
const DEFAULT_RUST_LOG: &'static str = "debug,actix_web=info";
@@ -171,9 +171,17 @@ pub async fn serve(server_state: ServerState) -> AnyhowResult<()>
.route(web::head().to(|| HttpResponse::Ok()))
)
.service(
web::resource("/upload_tts")
.route(web::post().to(upload_tts_model_handler))
.route(web::head().to(|| HttpResponse::Ok()))
web::scope("/tts")
.service(
web::resource("/upload")
.route(web::post().to(upload_tts_model_handler))
.route(web::head().to(|| HttpResponse::Ok()))
)
//.service(
// web::resource("/inference")
// .route(web::post().to())
// .route(web::head().to(|| HttpResponse::Ok()))
//)
)
.service(
web::scope("/w2l")