@@ -1,34 +1,5 @@
|
||||
use async_graphql_axum::{GraphQLRequest, GraphQLResponse};
|
||||
use axum::{
|
||||
extract::Extension,
|
||||
http::StatusCode,
|
||||
response::{Html, IntoResponse},
|
||||
};
|
||||
|
||||
use async_graphql::http::{playground_source, GraphQLPlaygroundConfig};
|
||||
use graphql::ComoSchema;
|
||||
|
||||
pub mod graphql;
|
||||
mod items;
|
||||
mod projects;
|
||||
|
||||
pub async fn graphql_handler(
|
||||
schema: Extension<ComoSchema>,
|
||||
req: GraphQLRequest,
|
||||
) -> Result<GraphQLResponse, StatusCode> {
|
||||
let req = req.into_inner();
|
||||
|
||||
Ok(schema.execute(req).await.into())
|
||||
}
|
||||
|
||||
//fn get_token_from_headers(headers: &HeaderMap) -> Option<Token> {
|
||||
// headers.get("Authorization").and_then(|value| {
|
||||
// let value = value.to_str().ok()?;
|
||||
// let value = value.strip_prefix("Bearer ")?;
|
||||
// Some(Token(value.to_string()))
|
||||
// })
|
||||
//}
|
||||
|
||||
pub async fn graphql_playground() -> impl IntoResponse {
|
||||
Html(playground_source(GraphQLPlaygroundConfig::new("/graphql")))
|
||||
}
|
||||
|
Reference in New Issue
Block a user