diff --git a/src/clients.rs b/src/clients.rs index bf1ea1d..6ece912 100644 --- a/src/clients.rs +++ b/src/clients.rs @@ -7,11 +7,6 @@ use uuid::Uuid; use crate::model::app_metadata::AppMetadata; use crate::model::metadata::Root; -pub trait Client { - fn app_metadata(&self) -> impl Future> + Send; - fn run_metadata(&self, id: Uuid) -> impl Future> + Send; -} - pub type ClientResult = Result; pub struct TiledClient { @@ -26,12 +21,10 @@ impl TiledClient { let body = response.text().await?; serde_json::from_str(&body).map_err(|e| ClientError::InvalidResponse(e, body)) } -} -impl Client for TiledClient { - async fn app_metadata(&self) -> ClientResult { + pub async fn app_metadata(&self) -> ClientResult { self.request::("/api/v1/").await } - async fn run_metadata(&self, id: Uuid) -> ClientResult { + pub async fn run_metadata(&self, id: Uuid) -> ClientResult { self.request::(&format!("/api/v1/metadata/{id}")) .await } diff --git a/src/handlers.rs b/src/handlers.rs index b0270fe..578e4ba 100644 --- a/src/handlers.rs +++ b/src/handlers.rs @@ -4,10 +4,9 @@ use async_graphql_axum::{GraphQLRequest, GraphQLResponse}; use axum::Extension; use axum::response::{Html, IntoResponse}; -use crate::clients::Client; use crate::model::TiledQuery; -pub async fn graphql_handler( +pub async fn graphql_handler( schema: Extension>, req: GraphQLRequest, ) -> GraphQLResponse { diff --git a/src/main.rs b/src/main.rs index 4299253..ac9044e 100644 --- a/src/main.rs +++ b/src/main.rs @@ -41,7 +41,7 @@ async fn serve(config: GlazedConfig) -> Result<(), Box> { .finish(); let app = Router::new() - .route("/graphql", post(graphql_handler::)) + .route("/graphql", post(graphql_handler)) .route("/graphiql", get(graphiql_handler)) .layer(Extension(schema)); diff --git a/src/model.rs b/src/model.rs index 45549a9..16bb7b6 100644 --- a/src/model.rs +++ b/src/model.rs @@ -5,7 +5,7 @@ pub(crate) mod metadata; use async_graphql::Object; use uuid::Uuid; -use crate::clients::{Client, ClientError, TiledClient}; +use crate::clients::{ClientError, TiledClient}; pub(crate) struct TiledQuery(pub TiledClient);