ft/adds word endpoint
This commit is contained in:
parent
a18aa55240
commit
ed5d6431ba
@ -5,6 +5,7 @@ edition = "2021"
|
|||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
axum = "0.7.4"
|
axum = "0.7.4"
|
||||||
|
rand = "0.8.5"
|
||||||
shuttle-axum = "0.45.0"
|
shuttle-axum = "0.45.0"
|
||||||
shuttle-runtime = "0.45.0"
|
shuttle-runtime = "0.45.0"
|
||||||
tokio = "1.28.2"
|
tokio = "1.28.2"
|
||||||
|
11
src/main.rs
11
src/main.rs
@ -1,15 +1,22 @@
|
|||||||
use axum::Router;
|
use axum::{routing::get, Router};
|
||||||
|
use rand::seq::SliceRandom;
|
||||||
use tower_http::services::ServeDir;
|
use tower_http::services::ServeDir;
|
||||||
|
|
||||||
#[shuttle_runtime::main]
|
#[shuttle_runtime::main]
|
||||||
async fn main() -> shuttle_axum::ShuttleAxum {
|
async fn main() -> shuttle_axum::ShuttleAxum {
|
||||||
let router = Router::new()
|
let router = Router::new()
|
||||||
// .route("/", get(hello_world))
|
// .route("/", get(hello_world))
|
||||||
.nest_service("/", ServeDir::new("frontend/dist"));
|
.nest_service("/", ServeDir::new("frontend/dist"))
|
||||||
|
.route("/word", get(word));
|
||||||
|
|
||||||
Ok(router.into())
|
Ok(router.into())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
async fn word() -> String {
|
||||||
|
let mut rng = rand::thread_rng();
|
||||||
|
WORDS.choose(&mut rng).unwrap().to_string()
|
||||||
|
}
|
||||||
|
|
||||||
static WORDS: &[&str; 5921] = &[
|
static WORDS: &[&str; 5921] = &[
|
||||||
"aalen", "Aales", "aalst", "aalte", "Aarau", "Aaron", "Aasee", "Aases", "Abart", "abbat",
|
"aalen", "Aales", "aalst", "aalte", "Aarau", "Aaron", "Aasee", "Aases", "Abart", "abbat",
|
||||||
"Abbau", "Abbey", "abbog", "Abdul", "Abeba", "Abels", "Abend", "abgab", "Abgas", "abhob",
|
"Abbau", "Abbey", "abbog", "Abdul", "Abeba", "Abels", "Abend", "abgab", "Abgas", "abhob",
|
||||||
|
Loading…
x
Reference in New Issue
Block a user