diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-11-05 01:00:05 +0100 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2022-11-05 17:24:54 +0100 |
commit | f2b946f1af005f6be15efd67f5b1508a30fa0c92 (patch) | |
tree | 5a5463bb11aaa7ac284e1c6c514832d53767a789 /indexer/src/main.rs | |
parent | Indexer: Actix: Use the same service handler with multiple routes (diff) | |
download | OSSE-f2b946f1af005f6be15efd67f5b1508a30fa0c92.tar.gz OSSE-f2b946f1af005f6be15efd67f5b1508a30fa0c92.tar.bz2 OSSE-f2b946f1af005f6be15efd67f5b1508a30fa0c92.zip |
Indexer+Frontend: Integrate with actix
Diffstat (limited to '')
-rw-r--r-- | indexer/src/main.rs | 15 |
1 files changed, 12 insertions, 3 deletions
diff --git a/indexer/src/main.rs b/indexer/src/main.rs index 952af96..7d5a1af 100644 --- a/indexer/src/main.rs +++ b/indexer/src/main.rs @@ -32,7 +32,7 @@ struct AppState { async fn main() -> std::io::Result<()> { println!("Hello, world! Im the indexer!"); - serve_http_endpoint("0.0.0.0", 4444).await + serve_http_endpoint("0.0.0.0", 8080).await } async fn serve_http_endpoint(address: &str, port: u16) -> std::io::Result<()> { @@ -45,7 +45,16 @@ async fn serve_http_endpoint(address: &str, port: u16) -> std::io::Result<()> { .wrap(cors) .app_data(shared_state.clone()) .service(add_resource) - .service(web::resource(["/search", "/search/", "/search/{query}"]).to(search)) + .service( + web::resource(["/api/search", "/api/search/", "/api/search/{query}"]).to(search), + ) + .service( + actix_web_lab::web::spa() + .index_file("./frontend/dist/index.html") + .static_resources_mount("/") + .static_resources_location("./frontend/dist") + .finish(), + ) //TODO: maybe separate gui backend from api? }) .bind((address, port))? .run() @@ -53,7 +62,7 @@ async fn serve_http_endpoint(address: &str, port: u16) -> std::io::Result<()> { } //TODO: sufficiently simmilar word in search (algorithm) -#[post("/resource")] +#[post("/api/resource")] async fn add_resource( data: web::Data<AppState>, resource: web::Json<CrawledResource>, |