2023-11-12 14:11:13 +01:00
|
|
|
#![allow(unused)]
|
|
|
|
|
use axum::extract::{Path, Query};
|
|
|
|
|
use axum::http::{Method, Uri};
|
|
|
|
|
use axum::response::{Html, IntoResponse, Response};
|
2023-11-25 08:48:09 +01:00
|
|
|
use axum::routing::{get, get_service, post, IntoMakeService};
|
2023-11-12 14:11:13 +01:00
|
|
|
use axum::Server;
|
|
|
|
|
use axum::{middleware, Json, Router};
|
|
|
|
|
use hyper::server::conn::AddrIncoming;
|
2023-11-25 08:48:09 +01:00
|
|
|
use serde::Deserialize;
|
|
|
|
|
use serde_json::{json, Value};
|
2023-11-12 14:11:13 +01:00
|
|
|
use std::net::SocketAddr;
|
|
|
|
|
use std::net::TcpListener;
|
|
|
|
|
|
|
|
|
|
pub type App = Server<AddrIncoming, IntoMakeService<Router>>;
|
|
|
|
|
|
2023-11-25 08:48:09 +01:00
|
|
|
#[derive(Deserialize)]
|
|
|
|
|
struct FormData {
|
|
|
|
|
email: String,
|
|
|
|
|
name: String,
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// API routing
|
2023-11-12 14:11:13 +01:00
|
|
|
fn app() -> Router {
|
2023-11-25 08:48:09 +01:00
|
|
|
Router::new()
|
|
|
|
|
.route("/health_check", get(|| async {}))
|
|
|
|
|
.route("/subscriptions", post(|| async {}))
|
2023-11-12 14:11:13 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// Start the server
|
|
|
|
|
pub fn run(listener: TcpListener) -> hyper::Result<App> {
|
|
|
|
|
let app = app();
|
|
|
|
|
let server = Server::from_tcp(listener)?.serve(app.into_make_service());
|
|
|
|
|
Ok(server)
|
|
|
|
|
}
|