Got 404 working again.
Some checks failed
Gitea Actions Demo / Explore-Gitea-Actions (push) Failing after 1s

This commit is contained in:
2026-02-03 11:37:58 -05:00
parent aa4a5b9b7c
commit 0dbf75d0c6
4 changed files with 89 additions and 73 deletions

View File

@@ -8,7 +8,7 @@ use axum::{
use clap::Parser;
//use morethantext::{ActionType, ErrorType, MoreThanText};
//use morethantext::{MoreThanText, MsgAction, Query};
use morethantext::MoreThanText;
use morethantext::{MTTError, MoreThanText};
use std::{collections::HashMap, convert::Infallible};
use tokio::{spawn, sync::mpsc::channel};
use tower_cookies::{Cookie, CookieManagerLayer, Cookies};
@@ -91,38 +91,30 @@ async fn mtt_conn(
_body: String,
) -> impl IntoResponse {
let (tx, mut rx) = channel(1);
/*
let _action = match method {
//Method::GET => MsgAction::Query(Query::new()),
//Method::GET => ActionType::Get,
//Method::POST => ActionType::Add,
//Method::PATCH => ActionType::Update,
_ => unreachable!("reouter should prevent this"),
};
*/
let _doc = match path.get("document") {
Some(result) => result.clone(),
None => "root".to_string(),
};
spawn(async move {
//tx.send(state.get_document(sess_id.0, action, doc, body))
tx.send(state.get_document()).await.unwrap();
match method {
Method::GET => match path.get("document") {
Some(doc) => tx.send(state.get_document(doc, "home")).await.unwrap(),
None => tx.send(state.get_document("page", "home")).await.unwrap(),
},
_ => unreachable!("reouter should prevent this"),
}
});
let reply = rx.recv().await.unwrap();
/*
let status = match reply.get_error() {
Some(err) => match err {
ErrorType::DocumentAlreadyExists => StatusCode::CONFLICT,
ErrorType::DocumentInvalidRequest => StatusCode::BAD_REQUEST,
ErrorType::DocumentNotFound => StatusCode::NOT_FOUND,
// _ => StatusCode::INTERNAL_SERVER_ERROR,
},
None => StatusCode::OK,
};
(status, reply.get_document())
*/
let status = StatusCode::OK;
(status, reply)
let mut result = "".to_string();
let mut status = StatusCode::OK;
match reply {
Ok(data) => {
result = data.clone();
}
Err(err) => {
status = match err {
MTTError::DocumentNotFound(_) => StatusCode::NOT_FOUND,
_ => StatusCode::INTERNAL_SERVER_ERROR,
};
}
}
(status, result)
}
#[cfg(test)]
@@ -195,7 +187,6 @@ mod servers {
}
#[tokio::test]
#[ignore]
async fn receive_file_not_found() {
let uri = "/something";
let app = create_app(MoreThanText::new()).await;