Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::error;

use async_graphql::{EmptyMutation, EmptySubscription, Schema};
use axum::http::StatusCode;
use axum::response::Html;
use axum::response::{Html, IntoResponse};
use axum::routing::{get, post};
use axum::{Extension, Router};

Expand Down Expand Up @@ -56,7 +56,7 @@ async fn serve(config: GlazedConfig) -> Result<(), Box<dyn error::Error>> {
.finish();

let app = Router::new()
.route("/graphql", post(graphql_handler))
.route("/graphql", post(graphql_handler).get(graphql_get_warning))
.route("/graphiql", get(graphiql_handler))
.fallback((
StatusCode::NOT_FOUND,
Expand All @@ -72,6 +72,14 @@ async fn serve(config: GlazedConfig) -> Result<(), Box<dyn error::Error>> {
.await?)
}

async fn graphql_get_warning() -> impl IntoResponse {
(
StatusCode::METHOD_NOT_ALLOWED,
[("Allow", "POST")],
Html(include_str!("../static/get_graphql_warning.html")),
)
}

async fn signal_handler() {
let mut term = signal(SignalKind::terminate()).expect("Failed to create SIGTERM listener");
let mut int = signal(SignalKind::interrupt()).expect("Failed to create SIGINT listener");
Expand Down
9 changes: 9 additions & 0 deletions static/get_graphql_warning.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
<!doctype html>
<html>
<head>
<title>Glazed</title>
</head>
<body>
<p>Requests should be made as graphql queries</p>
</body>
</html>
Loading