docs
This commit is contained in:
parent
a131b16538
commit
880bab0ae2
1 changed files with 4 additions and 2 deletions
|
@ -86,17 +86,17 @@ pub struct AppState {
|
||||||
games: Mutex<Vec<CAHGame>>,
|
games: Mutex<Vec<CAHGame>>,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Include utf-8 file at **compile** time.
|
// Include utf-8 files at **compile** time.
|
||||||
async fn index() -> Html<&'static str> {
|
async fn index() -> Html<&'static str> {
|
||||||
Html(std::include_str!("../test_client.html"))
|
Html(std::include_str!("../test_client.html"))
|
||||||
}
|
}
|
||||||
|
|
||||||
async fn spawnclients() -> Html<&'static str> {
|
async fn spawnclients() -> Html<&'static str> {
|
||||||
Html(std::include_str!("../spawnclients.html"))
|
Html(std::include_str!("../spawnclients.html"))
|
||||||
}
|
}
|
||||||
|
|
||||||
#[tokio::main]
|
#[tokio::main]
|
||||||
async fn main() -> Result<(), Box<dyn Error>> {
|
async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
|
// stuff for logging
|
||||||
tracing_subscriber::registry()
|
tracing_subscriber::registry()
|
||||||
.with(
|
.with(
|
||||||
tracing_subscriber::EnvFilter::try_from_default_env()
|
tracing_subscriber::EnvFilter::try_from_default_env()
|
||||||
|
@ -118,12 +118,14 @@ async fn main() -> Result<(), Box<dyn Error>> {
|
||||||
games,
|
games,
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// set routes and apply state
|
||||||
let app = Router::new()
|
let app = Router::new()
|
||||||
.route("/", get(index))
|
.route("/", get(index))
|
||||||
.route("/test", get(spawnclients))
|
.route("/test", get(spawnclients))
|
||||||
.route("/websocket", get(websocket_handler))
|
.route("/websocket", get(websocket_handler))
|
||||||
.with_state(app_state);
|
.with_state(app_state);
|
||||||
|
|
||||||
|
// send it
|
||||||
let listener = tokio::net::TcpListener::bind("0.0.0.0:3030").await?;
|
let listener = tokio::net::TcpListener::bind("0.0.0.0:3030").await?;
|
||||||
tracing::debug!("listening on {}", listener.local_addr()?);
|
tracing::debug!("listening on {}", listener.local_addr()?);
|
||||||
axum::serve(
|
axum::serve(
|
||||||
|
|
Loading…
Add table
Reference in a new issue