Skip to content
Snippets Groups Projects
Commit f7efabe3 authored by Etienne Palanga's avatar Etienne Palanga
Browse files

add post endpoint for larger schmfying needs

parent 57937a1b
No related branches found
No related tags found
No related merge requests found
......@@ -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"
......
[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"
......
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()
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment