From 69a78d51f5662faac06ee3b1be400a593f1b5fe0 Mon Sep 17 00:00:00 2001 From: Your Name Date: Sun, 25 May 2025 15:22:14 +1200 Subject: [PATCH] Bug fixing --- src/server.cpp | 124 +++++++++++++++++++++++++++++++++++++++++++++++-- 1 file changed, 119 insertions(+), 5 deletions(-) diff --git a/src/server.cpp b/src/server.cpp index 2235bce..8fa37ff 100644 --- a/src/server.cpp +++ b/src/server.cpp @@ -140,6 +140,120 @@ void Server::stop() { } } +std::string welcome_page() { + return R"( + + + + + + Simple Object Storage + + + +
+
+

Simple Object Storage

+

A lightweight, efficient object storage service

+
+ +
+
+

Simple Storage

+

Store and retrieve objects using unique hashes or label:tag combinations.

+
+
+

RESTful API

+

Access your objects through a clean, intuitive REST API interface.

+
+
+

Secure Access

+

Protected endpoints with token-based authentication for write operations.

+
+
+ +
+

Available Endpoints

+
    +
  • GET /object/{hash} - Retrieve an object by hash
  • +
  • GET /hash/{label:tag} - Get hash for a label:tag
  • +
  • GET /exists/{hash} - Check if an object exists
  • +
  • GET /dir - List all objects
  • +
  • PUT /upload - Upload a new object
  • +
  • GET /meta/{hash} - Get object metadata
  • +
+
+
+ + +)"; +} + void Server::setup_routes() { // Add CORS preflight handler for all routes server_.Options(".*", [this](const httplib::Request& req, httplib::Response& res) { @@ -151,14 +265,14 @@ void Server::setup_routes() { add_cors_headers(req, res); }); - const std::string welcome_page = "

simple_object_storage Template Registry

"; + // Welcome page - server_.Get("/", [welcome_page](const httplib::Request&, httplib::Response& res) { - res.set_content(welcome_page, "text/html"); + server_.Get("/", [](const httplib::Request&, httplib::Response& res) { + res.set_content(welcome_page(), "text/html"); }); - server_.Get("/index.html", [welcome_page](const httplib::Request&, httplib::Response& res) { - res.set_content(welcome_page, "text/html"); + server_.Get("/index.html", [](const httplib::Request&, httplib::Response& res) { + res.set_content(welcome_page(), "text/html"); }); // Get object by hash or label:tag