From f7efabe3e93e19d9fd5189e7f7ecbb4ed7ea5e7c Mon Sep 17 00:00:00 2001
From: Etienne Palanga <me@skadic.moe>
Date: Wed, 8 May 2024 15:06:14 +0200
Subject: [PATCH] add post endpoint for larger schmfying needs

---
 Cargo.lock  | 3 +--
 Cargo.toml  | 4 ++--
 src/main.rs | 8 ++++++--
 3 files changed, 9 insertions(+), 6 deletions(-)

diff --git a/Cargo.lock b/Cargo.lock
index 33b9250..e539c0c 100644
--- a/Cargo.lock
+++ b/Cargo.lock
@@ -592,8 +592,7 @@ checksum = "f3cb5ba0dc43242ce17de99c180e96db90b235b8a9fdc9543c96d2209116bd9f"
 [[package]]
 name = "schmfy"
 version = "0.2.1"
-source = "registry+https://github.com/rust-lang/crates.io-index"
-checksum = "a258529f4dfcece66eff7179d53246cdf5eab89acf586d76ec129b13ab827f0c"
+source = "git+https://gitlab.fachschaften.org/skadic/schmfy#2a7a7768c6377d03cd59d5e7a661d89957e5868e"
 
 [[package]]
 name = "schmfy_express"
diff --git a/Cargo.toml b/Cargo.toml
index bfb8982..5279710 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
 [package]
 name = "schmfy_express"
-version = "0.2.0"
+version = "0.2.1"
 edition = "2021"
 
 # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
@@ -10,7 +10,7 @@ axum = "0.7.5"
 dotenvy = "0.15.7"
 futures = "0.3.30"
 miette = { version = "7.2.0", features = ["fancy"] }
-schmfy = "0.2.1"
+schmfy = { git = "https://gitlab.fachschaften.org/skadic/schmfy"}
 serde = { version = "1.0.200", features = ["derive"] }
 tokio = { version = "1.37.0", features = ["rt-multi-thread", "macros", "signal"] }
 tracing = "0.1.40"
diff --git a/src/main.rs b/src/main.rs
index cb32bbb..9062108 100644
--- a/src/main.rs
+++ b/src/main.rs
@@ -1,4 +1,4 @@
-use axum::{extract::Query, response::Html, routing::get, Router};
+use axum::{extract::Query, response::Html, routing::get, Json, Router};
 use dotenvy::dotenv;
 use miette::{Context, IntoDiagnostic};
 use std::net::Ipv4Addr;
@@ -18,7 +18,7 @@ async fn main() -> miette::Result<()> {
     }
     let router = Router::<()>::new()
         .route("/", get(home))
-        .route("/schmfy", get(schmfy));
+        .route("/schmfy", get(schmfy).post(schmfy_post));
 
     let address = std::env::var(SCHMFY_HOST)
         .into_diagnostic()
@@ -64,6 +64,10 @@ async fn schmfy(Query(Input { input }): Query<Input>) -> String {
     schmfy::schmfy(input.as_str())
 }
 
+async fn schmfy_post(Json(Input { input }): Json<Input>) -> String {
+    schmfy::schmfy(input.as_str())
+}
+
 async fn shutdown_signal() {
     let ctrl_c = async {
         signal::ctrl_c()
-- 
GitLab