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;
14
15use crate::BUILD_INFO;
16
17#[derive(Template)]
18#[template(path = "home.html")]
19struct HomeTemplate<'a> {
20    version: &'a str,
21    build_sha: &'static str,
22    profiling: bool,
23}
24
25pub async fn handle_home(profiling: bool) -> impl IntoResponse {
26    mz_http_util::template_response(HomeTemplate {
27        version: BUILD_INFO.version,
28        build_sha: BUILD_INFO.sha,
29        profiling,
30    })
31}
32
33mz_http_util::make_handle_static!(
34    dir_1: ::include_dir::include_dir!("$CARGO_MANIFEST_DIR/src/http/static"),
35    dir_2: ::include_dir::include_dir!("$OUT_DIR/src/http/static"),
36    prod_base_path: "src/http/static",
37    dev_base_path: "src/http/static-dev",
38);