mirror of
https://github.com/perstarkse/minne.git
synced 2026-03-20 00:24:30 +01:00
tera wip
This commit is contained in:
@@ -10,6 +10,7 @@ use zettle_db::{
|
||||
rabbitmq::{publisher::RabbitMQProducer, RabbitMQConfig},
|
||||
server::routes::{
|
||||
file::{delete_file_handler, get_file_handler, update_file_handler, upload_handler},
|
||||
index::index_handler,
|
||||
ingress::ingress_handler,
|
||||
query::query_handler,
|
||||
queue_length::queue_length_handler,
|
||||
@@ -44,20 +45,21 @@ async fn main() -> Result<(), Box<dyn std::error::Error>> {
|
||||
|
||||
// Create Axum router
|
||||
let app = Router::new()
|
||||
// Ingress routes
|
||||
.route("/ingress", post(ingress_handler))
|
||||
.route("/message_count", get(queue_length_handler))
|
||||
.layer(Extension(producer))
|
||||
// File routes
|
||||
.route("/file", post(upload_handler))
|
||||
.layer(DefaultBodyLimit::max(1024 * 1024 * 1024))
|
||||
.route("/file/:uuid", get(get_file_handler))
|
||||
.route("/file/:uuid", put(update_file_handler))
|
||||
.route("/file/:uuid", delete(delete_file_handler))
|
||||
// Query routes
|
||||
.route("/query", post(query_handler))
|
||||
.layer(Extension(db_client))
|
||||
.route(
|
||||
"/hello_world",
|
||||
get(zettle_db::server::routes::hello_world::hello_world_handler),
|
||||
)
|
||||
// Html routes
|
||||
.route("/", get(index_handler))
|
||||
.layer(Extension(tera));
|
||||
|
||||
tracing::info!("Listening on 0.0.0.0:3000");
|
||||
|
||||
@@ -1,10 +0,0 @@
|
||||
use axum::Extension;
|
||||
use tera::{Context, Tera};
|
||||
|
||||
use crate::error::ApiError;
|
||||
|
||||
pub async fn hello_world_handler(Extension(tera): Extension<Tera>) -> Result<String, ApiError> {
|
||||
let output = tera.render("hello_world.html", &Context::new()).unwrap();
|
||||
|
||||
Ok(output)
|
||||
}
|
||||
10
src/server/routes/index.rs
Normal file
10
src/server/routes/index.rs
Normal file
@@ -0,0 +1,10 @@
|
||||
use axum::{response::Html, Extension};
|
||||
use tera::{Context, Tera};
|
||||
|
||||
use crate::error::ApiError;
|
||||
|
||||
pub async fn index_handler(Extension(tera): Extension<Tera>) -> Result<Html<String>, ApiError> {
|
||||
let output = tera.render("index.html", &Context::new()).unwrap();
|
||||
|
||||
Ok(output.into())
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
pub mod file;
|
||||
pub mod hello_world;
|
||||
pub mod index;
|
||||
pub mod ingress;
|
||||
pub mod query;
|
||||
pub mod queue_length;
|
||||
|
||||
@@ -1,4 +0,0 @@
|
||||
<h1>Hello</h1>
|
||||
<div>Hello</div>
|
||||
<p>HI</p>
|
||||
wowoow
|
||||
11
src/server/templates/index.html
Normal file
11
src/server/templates/index.html
Normal file
@@ -0,0 +1,11 @@
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
|
||||
<head>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
Hello world!
|
||||
</body>
|
||||
|
||||
</html>
|
||||
Reference in New Issue
Block a user