mirror of
https://github.com/perstarkse/minne.git
synced 2026-04-22 08:48:30 +02:00
refactor: moved routes
This commit is contained in:
@@ -2,6 +2,6 @@ pub mod error;
|
|||||||
pub mod ingress;
|
pub mod ingress;
|
||||||
pub mod rabbitmq;
|
pub mod rabbitmq;
|
||||||
pub mod retrieval;
|
pub mod retrieval;
|
||||||
pub mod routes;
|
pub mod server;
|
||||||
pub mod storage;
|
pub mod storage;
|
||||||
pub mod utils;
|
pub mod utils;
|
||||||
|
|||||||
1
src/server/mod.rs
Normal file
1
src/server/mod.rs
Normal file
@@ -0,0 +1 @@
|
|||||||
|
pub mod routes;
|
||||||
@@ -1,3 +1,4 @@
|
|||||||
pub mod file;
|
pub mod file;
|
||||||
pub mod ingress;
|
pub mod ingress;
|
||||||
|
pub mod query;
|
||||||
pub mod queue_length;
|
pub mod queue_length;
|
||||||
17
src/server/routes/query.rs
Normal file
17
src/server/routes/query.rs
Normal file
@@ -0,0 +1,17 @@
|
|||||||
|
use crate::storage::db::SurrealDbClient;
|
||||||
|
use axum::{http::StatusCode, response::IntoResponse, Extension, Json};
|
||||||
|
use serde::Deserialize;
|
||||||
|
use std::sync::Arc;
|
||||||
|
use tracing::{error, info};
|
||||||
|
|
||||||
|
#[derive(Debug, Deserialize)]
|
||||||
|
pub struct QueryInput {
|
||||||
|
query: String,
|
||||||
|
}
|
||||||
|
|
||||||
|
pub async fn query_handler(
|
||||||
|
Extension(db_client): Extension<Arc<SurrealDbClient>>,
|
||||||
|
Json(query): Json<QueryInput>,
|
||||||
|
) -> impl IntoResponse {
|
||||||
|
info!("Received input: {:?}", query);
|
||||||
|
}
|
||||||
@@ -1,11 +1,14 @@
|
|||||||
use axum::{http::StatusCode, response::{IntoResponse, Response}};
|
use axum::{
|
||||||
|
http::StatusCode,
|
||||||
|
response::{IntoResponse, Response},
|
||||||
|
};
|
||||||
use tracing::{error, info};
|
use tracing::{error, info};
|
||||||
|
|
||||||
use crate::rabbitmq::{consumer::RabbitMQConsumer, RabbitMQConfig};
|
use crate::rabbitmq::{consumer::RabbitMQConsumer, RabbitMQConfig};
|
||||||
|
|
||||||
pub async fn queue_length_handler() -> Response {
|
pub async fn queue_length_handler() -> Response {
|
||||||
info!("Getting queue length");
|
info!("Getting queue length");
|
||||||
|
|
||||||
// Set up RabbitMQ config
|
// Set up RabbitMQ config
|
||||||
let config = RabbitMQConfig {
|
let config = RabbitMQConfig {
|
||||||
amqp_addr: "amqp://localhost".to_string(),
|
amqp_addr: "amqp://localhost".to_string(),
|
||||||
@@ -26,11 +29,14 @@ pub async fn queue_length_handler() -> Response {
|
|||||||
|
|
||||||
// Return the queue length with a 200 OK status
|
// Return the queue length with a 200 OK status
|
||||||
(StatusCode::OK, queue_length.to_string()).into_response()
|
(StatusCode::OK, queue_length.to_string()).into_response()
|
||||||
},
|
}
|
||||||
Err(e) => {
|
Err(e) => {
|
||||||
error!("Failed to create consumer: {:?}", e);
|
error!("Failed to create consumer: {:?}", e);
|
||||||
(StatusCode::INTERNAL_SERVER_ERROR, "Failed to connect to RabbitMQ".to_string()).into_response()
|
(
|
||||||
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
|
"Failed to connect to RabbitMQ".to_string(),
|
||||||
|
)
|
||||||
|
.into_response()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Reference in New Issue
Block a user