zero2prod_axum/src/lib.rs

30 lines
769 B
Rust
Raw Normal View History

#![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-12-15 23:13:00 +01:00
use axum::serve::Serve;
use axum::{middleware, Json, Router};
2023-11-25 08:48:09 +01:00
use serde::Deserialize;
use serde_json::{json, Value};
use std::net::SocketAddr;
2023-12-15 23:13:00 +01:00
use tokio::net::TcpListener;
2023-11-25 08:48:09 +01:00
#[derive(Deserialize)]
struct FormData {
email: String,
name: String,
}
/// API routing
2023-12-15 23:13:00 +01:00
pub fn app() -> Router {
2023-11-25 08:48:09 +01:00
Router::new()
.route("/health_check", get(|| async {}))
.route("/subscriptions", post(|| async {}))
}
/// Start the server
2023-12-15 23:13:00 +01:00
pub fn run(listener: TcpListener) -> Serve<IntoMakeService<Router>, Router> {
axum::serve(listener, app().into_make_service())
}