This commit is contained in:
2
build.sh
2
build.sh
@@ -5,7 +5,6 @@ set -e
|
|||||||
|
|
||||||
# DIRECTORIES
|
# DIRECTORIES
|
||||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
CACHE_DIR="${SCRIPT_DIR}/cache"
|
|
||||||
EXE_DIR="${SCRIPT_DIR}/output"
|
EXE_DIR="${SCRIPT_DIR}/output"
|
||||||
PROJECTNAME="simple_object_storage"
|
PROJECTNAME="simple_object_storage"
|
||||||
|
|
||||||
@@ -62,7 +61,6 @@ cp build_arm64/${PROJECTNAME} ${EXE_DIR}/${PROJECTNAME}.arm64
|
|||||||
#--------------------------------
|
#--------------------------------
|
||||||
cd $SCRIPT_DIR
|
cd $SCRIPT_DIR
|
||||||
|
|
||||||
mkdir -p ${CACHE_DIR}
|
|
||||||
mkdir -p ${EXE_DIR}
|
mkdir -p ${EXE_DIR}
|
||||||
|
|
||||||
BUILDSTR="amd64"
|
BUILDSTR="amd64"
|
||||||
|
@@ -5,9 +5,7 @@ set -e
|
|||||||
|
|
||||||
# DIRECTORIES
|
# DIRECTORIES
|
||||||
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)
|
||||||
#CACHE_DIR="${SCRIPT_DIR}/cache"
|
|
||||||
EXE_DIR="${SCRIPT_DIR}/output"
|
EXE_DIR="${SCRIPT_DIR}/output"
|
||||||
#BUILD_DIR="${SCRIPT_DIR}/build"
|
|
||||||
|
|
||||||
# FUNCTIONS
|
# FUNCTIONS
|
||||||
function title() {
|
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) {
|
server_.Get("/index.html", [](const httplib::Request&, httplib::Response& res) {
|
||||||
res.set_content(welcome_page(), "text/html");
|
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
|
// Get hash for label:tag
|
||||||
server_.Get("/hash/(.*)", [this](const httplib::Request& req, httplib::Response& res) {
|
server_.Get("/hash/(.*)", [this](const httplib::Request& req, httplib::Response& res) {
|
||||||
handle_get_hash(req, 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) {
|
server_.Get("/status", [this](const httplib::Request& req, httplib::Response& res) {
|
||||||
res.set_content(nlohmann::json({{"result", "success"}, {"status", "ok"}}).dump(), "application/json");
|
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) {
|
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
|
set -euo pipefail
|
||||||
|
|
||||||
|
|
||||||
HOSTURL="$1"
|
HOSTURL="${1:-http://localhost:8123}"
|
||||||
if [ -z "${HOSTURL}" ]; then
|
|
||||||
HOSTURL="http://localhost:8123"
|
|
||||||
fi
|
|
||||||
|
|
||||||
|
|
||||||
#------------------------------------------------------------------------------------------------
|
#------------------------------------------------------------------------------------------------
|
||||||
@@ -37,6 +34,14 @@ cat << EOF
|
|||||||
|
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
|
|
||||||
|
title "TESTING ${HOSTURL}"
|
||||||
|
|
||||||
|
cat << EOF
|
||||||
|
|
||||||
|
|
||||||
|
EOF
|
||||||
|
|
||||||
# Test 0: Verify the script is running
|
# Test 0: Verify the script is running
|
||||||
title "0: Verify the server is running"
|
title "0: Verify the server is running"
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user