aboutsummaryrefslogtreecommitdiff
path: root/zenserver/experimental/frontend.cpp
diff options
context:
space:
mode:
authorMartin Ridgers <[email protected]>2022-03-16 14:58:34 +0100
committerMartin Ridgers <[email protected]>2022-03-16 14:58:34 +0100
commitef2f48fbfa3dc5d7a61baf6ccfd6e41b6c3eb895 (patch)
tree2afa4ea4993869a10e37baa6062f8f4f3eca91f0 /zenserver/experimental/frontend.cpp
parentCorrected linux install (diff)
parentFixed typo (diff)
downloadzen-ef2f48fbfa3dc5d7a61baf6ccfd6e41b6c3eb895.tar.xz
zen-ef2f48fbfa3dc5d7a61baf6ccfd6e41b6c3eb895.zip
Merge branch 'dashboard-zipfs'
Diffstat (limited to 'zenserver/experimental/frontend.cpp')
-rw-r--r--zenserver/experimental/frontend.cpp119
1 files changed, 0 insertions, 119 deletions
diff --git a/zenserver/experimental/frontend.cpp b/zenserver/experimental/frontend.cpp
deleted file mode 100644
index 4bd3ec90a..000000000
--- a/zenserver/experimental/frontend.cpp
+++ /dev/null
@@ -1,119 +0,0 @@
-// Copyright Epic Games, Inc. All Rights Reserved.
-
-#include "frontend.h"
-
-#include <zencore/filesystem.h>
-#include <zencore/string.h>
-
-namespace zen {
-
-namespace html {
-
- constexpr std::string_view Index = R"(
-<!DOCTYPE html>
-<html>
-<head>
-<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" integrity="sha384-F3w7mX95PdgyTmZZMECAngseQB83DfGTowi0iMjiWaeVhAn4FJkqJByhZMI3AhiU" crossorigin="anonymous">
-<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.min.js" integrity="sha384-skAcpIdS7UcVUC05LJ9Dxay8AXcDYfBJqt1CJ85S/CFujBsIzCIv+l9liuYLaMQ/" crossorigin="anonymous"></script>
-<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/[email protected]/font/bootstrap-icons.css">
-<style type="text/css">
-body {
- background-color: #fafafa;
-}
-</style>
-<script type="text/javascript">
- const getCacheStats = () => {
- const opts = { headers: { "Accept": "application/json" } };
- fetch("/stats/z$", opts)
- .then(response => {
- if (!response.ok) {
- throw Error(response.statusText);
- }
- return response.json();
- })
- .then(json => {
- document.getElementById("status").innerHTML = "connected"
- document.getElementById("stats").innerHTML = JSON.stringify(json, null, 4);
- })
- .catch(error => {
- document.getElementById("status").innerHTML = "disconnected"
- document.getElementById("stats").innerHTML = ""
- console.log(error);
- })
- .finally(() => {
- window.setTimeout(getCacheStats, 1000);
- });
- };
- getCacheStats();
-</script>
-</head>
-<body>
- <div class="container">
- <div class="row">
- <div class="text-center mt-5">
- <pre>
-__________ _________ __
-\____ / ____ ____ / _____/_/ |_ ____ _______ ____
- / / _/ __ \ / \ \_____ \ \ __\ / _ \ \_ __ \_/ __ \
- / /_ \ ___/ | | \ / \ | | ( <_> ) | | \/\ ___/
-/_______ \ \___ >|___| //_______ / |__| \____/ |__| \___ >
- \/ \/ \/ \/ \/
- </pre>
- <pre id="status"/>
- </div>
- </div>
- <div class="row">
- <pre class="mb-0">Z$:</pre>
- <pre id="stats"></pre>
- <div>
- </div>
-</body>
-</html>
-)";
-
-} // namespace html
-
-HttpFrontendService::HttpFrontendService(std::filesystem::path Directory) : m_Directory(Directory)
-{
-}
-
-HttpFrontendService::~HttpFrontendService()
-{
-}
-
-const char*
-HttpFrontendService::BaseUri() const
-{
- return "/dashboard"; // in order to use the root path we need to remove HttpAddUrlToUrlGroup in HttpSys.cpp
-}
-
-void
-HttpFrontendService::HandleRequest(zen::HttpServerRequest& Request)
-{
- using namespace std::literals;
-
- if (m_Directory.empty())
- {
- Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kHTML, html::Index);
- }
- else
- {
- std::string_view Uri = Request.RelativeUri();
- std::filesystem::path RelPath{Uri.empty() ? "index.html" : Uri};
- std::filesystem::path AbsPath = m_Directory / RelPath;
-
- FileContents File = ReadFile(AbsPath);
-
- if (!File.ErrorCode)
- {
- // TODO: Map file extension to MIME type
- Request.WriteResponse(HttpResponseCode::OK, HttpContentType::kHTML, File.Data[0]);
- }
- else
- {
- return Request.WriteResponse(HttpResponseCode::NotFound, HttpContentType::kText, "Ooops!"sv);
- }
- }
-}
-
-} // namespace zen