Add working API calls, fix warnings
All checks were successful
Build Crate / build (push) Successful in 7m16s

This commit is contained in:
2023-09-21 20:03:16 -04:00
parent 30b637dfef
commit 0a68829d6c
12 changed files with 147 additions and 69 deletions

View File

@@ -2,38 +2,28 @@ mod components;
mod templates;
mod data;
mod error_views;
#[cfg(engine)]
mod handler;
mod endpoints;
use perseus::prelude::*;
use sycamore::prelude::view;
#[cfg(engine)]
use axum::{
body::Body,
extract::{Path, Query},
http::{Request, StatusCode},
response::{IntoResponse, Response},
routing::{get, get_service},
Router,
};
#[cfg(engine)]
use perseus::turbine::ApiResponse as PerseusApiResponse;
use axum::routing::post;
#[cfg(engine)]
use perseus::{
i18n::TranslationsManager,
path::*,
server::ServerOptions,
stores::MutableStore,
turbine::{SubsequentLoadQueryParams, Turbine},
turbine::Turbine,
};
#[cfg(engine)]
use tower_http::services::{ServeDir, ServeFile};
use crate::endpoints::MATCH;
#[cfg(engine)]
use crate::handler::post_match;
async fn print_something() {
println!("haha");
}
#[cfg(engine)]
pub async fn dflt_server<M: MutableStore + 'static, T: TranslationsManager + 'static>(
turbine: &'static Turbine<M, T>,
@@ -46,7 +36,7 @@ pub async fn dflt_server<M: MutableStore + 'static, T: TranslationsManager + 'st
.parse()
.expect("Invalid address provided to bind to.");
let mut app = perseus_axum::get_router(turbine, opts).await;
app = app.route("/api/test", get(print_something));
app = app.route(MATCH, post(post_match));
axum::Server::bind(&addr)
.serve(app.into_make_service())
@@ -59,7 +49,7 @@ pub fn main<G: Html>() -> PerseusApp<G> {
env_logger::init();
PerseusApp::new()
.global_state_creator(crate::data::global_state::get_global_state_creator())
.global_state_creator(crate::templates::global_state::get_global_state_creator())
.template(crate::templates::index::get_template())
.template(crate::templates::add_game_form::get_template())
.template(crate::templates::one_v_one_board::get_template())