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
1 change: 1 addition & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ COPY ./Cargo.toml ./Cargo.toml
COPY ./Cargo.lock ./Cargo.lock
RUN cargo build --release --target x86_64-unknown-linux-musl

COPY ./static ./static
COPY ./src ./src

RUN cargo build --release --target x86_64-unknown-linux-musl
Expand Down
6 changes: 6 additions & 0 deletions src/main.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
use std::error;

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

Expand Down Expand Up @@ -54,6 +56,10 @@ async fn serve(config: GlazedConfig) -> Result<(), Box<dyn error::Error>> {
let app = Router::new()
.route("/graphql", post(graphql_handler))
.route("/graphiql", get(graphiql_handler))
.fallback((
StatusCode::NOT_FOUND,
Html(include_str!("../static/404.html")),
))
.layer(Extension(schema));

let listener = tokio::net::TcpListener::bind(config.bind_address).await?;
Expand Down
15 changes: 15 additions & 0 deletions static/404.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
<!doctype html>
<html>
<head>
<title>Glazed</title>
</head>
<body>
<h1>GraphQL interface to Tiled</h1>
<p>
Service is available at
<a href="/graphql">/graphql</a>.
Playground is available for testing at
<a href="/graphiql">/graphiql</a>
</p>
</body>
</html>
Loading