mvp file to ingress fn

This commit is contained in:
Per Stark
2024-09-25 14:20:19 +02:00
parent 5c52bdc983
commit 827fefad06
5 changed files with 70 additions and 13 deletions

View File

@@ -1,5 +1,3 @@
// === Contents of ./routes/file.rs ===
use axum::{
extract::Path,
response::IntoResponse,
@@ -9,13 +7,12 @@ use axum::{
use axum_typed_multipart::{TypedMultipart, FieldData, TryFromMultipart};
use serde_json::json;
use tempfile::NamedTempFile;
use tracing::{error, info};
use tracing::info;
use uuid::Uuid;
use crate::{
models::file_info::{FileError, FileInfo},
redis::client::RedisClient,
rabbitmq::publisher::RabbitMQProducer,
};
#[derive(Debug, TryFromMultipart)]

View File

@@ -3,7 +3,7 @@ use std::sync::Arc;
use axum::{http::StatusCode, response::IntoResponse, Extension, Json};
use tracing::{error, info};
use crate::{models::ingress::{IngressContent, IngressInput}, rabbitmq::publisher::RabbitMQProducer};
use crate::{models::ingress::{IngressContent, IngressInput}, rabbitmq::publisher::RabbitMQProducer, redis::client::RedisClient};
pub async fn ingress_handler(
Extension(producer): Extension<Arc<RabbitMQProducer>>,
@@ -11,7 +11,8 @@ pub async fn ingress_handler(
) -> impl IntoResponse {
info!("Recieved input: {:?}", input);
if let Ok(content) = IngressContent::new(input).await {
let redis_client = RedisClient::new("redis://127.0.0.1/");
if let Ok(content) = IngressContent::new(input, &redis_client).await {
// Publish content to RabbitMQ (or other system)
match producer.publish(&content).await {