Skip to main content

mz_environmentd/http/
root.rs

1// Copyright Materialize, Inc. and contributors. All rights reserved.
2//
3// Use of this software is governed by the Business Source License
4// included in the LICENSE file.
5//
6// As of the Change Date specified in that file, in accordance with
7// the Business Source License, use of this software will be governed
8// by the Apache License, Version 2.0.
9
10//! HTTP endpoints for the homepage and static files.
11
12use askama::Template;
13use axum::response::IntoResponse;
14use mz_server_core::listeners::HttpRoutesEnabled;
15
16use crate::BUILD_INFO;
17
18#[derive(Template)]
19#[template(path = "home.html")]
20struct HomeTemplate<'a> {
21    version: &'a str,
22    build_sha: &'static str,
23    routes_enabled: HttpRoutesEnabled,
24}
25
26pub async fn handle_home(routes_enabled: HttpRoutesEnabled) -> impl IntoResponse {
27    mz_http_util::template_response(HomeTemplate {
28        version: BUILD_INFO.version,
29        build_sha: BUILD_INFO.sha,
30        routes_enabled,
31    })
32}
33
34mz_http_util::make_handle_static!(
35    dir_1: ::include_dir::include_dir!("$CARGO_MANIFEST_DIR/src/http/static"),
36    dir_2: ::include_dir::include_dir!("$OUT_DIR/src/http/static"),
37    prod_base_path: "src/http/static",
38    dev_base_path: "src/http/static-dev",
39);