This commit is contained in:
2
build.sh
2
build.sh
@@ -5,7 +5,6 @@ set -e
|
||||
|
||||
# DIRECTORIES
|
||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
CACHE_DIR="${SCRIPT_DIR}/cache"
|
||||
EXE_DIR="${SCRIPT_DIR}/output"
|
||||
PROJECTNAME="simple_object_storage"
|
||||
|
||||
@@ -62,7 +61,6 @@ cp build_arm64/${PROJECTNAME} ${EXE_DIR}/${PROJECTNAME}.arm64
|
||||
#--------------------------------
|
||||
cd $SCRIPT_DIR
|
||||
|
||||
mkdir -p ${CACHE_DIR}
|
||||
mkdir -p ${EXE_DIR}
|
||||
|
||||
BUILDSTR="amd64"
|
||||
|
@@ -5,9 +5,7 @@ set -e
|
||||
|
||||
# DIRECTORIES
|
||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||
#CACHE_DIR="${SCRIPT_DIR}/cache"
|
||||
EXE_DIR="${SCRIPT_DIR}/output"
|
||||
#BUILD_DIR="${SCRIPT_DIR}/build"
|
||||
|
||||
# FUNCTIONS
|
||||
function title() {
|
||||
|
@@ -153,25 +153,10 @@ void Server::setup_routes() {
|
||||
});
|
||||
|
||||
|
||||
// Welcome page
|
||||
server_.Get("/(.*)", [this](const httplib::Request& req, httplib::Response& res) {
|
||||
if (req.path == "/") {
|
||||
res.set_content(welcome_page(), "text/html");
|
||||
return;
|
||||
}
|
||||
// if the path is not /, then it's a hash or label:tag
|
||||
handle_get_object(req, res);
|
||||
});
|
||||
|
||||
server_.Get("/index.html", [](const httplib::Request&, httplib::Response& res) {
|
||||
res.set_content(welcome_page(), "text/html");
|
||||
});
|
||||
|
||||
// Get object by hash or label:tag
|
||||
server_.Get("/object/(.*)", [this](const httplib::Request& req, httplib::Response& res) {
|
||||
handle_get_object(req, res);
|
||||
});
|
||||
|
||||
// Get hash for label:tag
|
||||
server_.Get("/hash/(.*)", [this](const httplib::Request& req, httplib::Response& res) {
|
||||
handle_get_hash(req, res);
|
||||
@@ -218,6 +203,22 @@ void Server::setup_routes() {
|
||||
server_.Get("/status", [this](const httplib::Request& req, httplib::Response& res) {
|
||||
res.set_content(nlohmann::json({{"result", "success"}, {"status", "ok"}}).dump(), "application/json");
|
||||
});
|
||||
|
||||
// Get object by hash or label:tag
|
||||
server_.Get("/object/(.*)", [this](const httplib::Request& req, httplib::Response& res) {
|
||||
handle_get_object(req, res);
|
||||
});
|
||||
|
||||
// Welcome page and download object.
|
||||
server_.Get("/(.*)", [this](const httplib::Request& req, httplib::Response& res) {
|
||||
if (req.path == "/") {
|
||||
res.set_content(welcome_page(), "text/html");
|
||||
return;
|
||||
}
|
||||
// if the path is not /, then it's a hash or label:tag
|
||||
handle_get_object(req, res);
|
||||
});
|
||||
|
||||
}
|
||||
|
||||
void Server::handle_cors_preflight(const httplib::Request& req, httplib::Response& res) {
|
||||
|
13
test.sh
13
test.sh
@@ -3,10 +3,7 @@
|
||||
set -euo pipefail
|
||||
|
||||
|
||||
HOSTURL="$1"
|
||||
if [ -z "${HOSTURL}" ]; then
|
||||
HOSTURL="http://localhost:8123"
|
||||
fi
|
||||
HOSTURL="${1:-http://localhost:8123}"
|
||||
|
||||
|
||||
#------------------------------------------------------------------------------------------------
|
||||
@@ -37,6 +34,14 @@ cat << EOF
|
||||
|
||||
|
||||
EOF
|
||||
|
||||
title "TESTING ${HOSTURL}"
|
||||
|
||||
cat << EOF
|
||||
|
||||
|
||||
EOF
|
||||
|
||||
# Test 0: Verify the script is running
|
||||
title "0: Verify the server is running"
|
||||
|
||||
|
Reference in New Issue
Block a user