From 30cff0f11149ea2a85b025d143aa4a46369c87f0 Mon Sep 17 00:00:00 2001 From: Aleksey Veresov Date: Mon, 7 Dec 2020 10:20:37 +0300 Subject: . --- entry | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 entry (limited to 'entry') diff --git a/entry b/entry new file mode 100644 index 0000000..b42d378 --- /dev/null +++ b/entry @@ -0,0 +1,18 @@ +#!/bin/bash +# This is the process to be called. +# $proc and $base (initial working directory) is already set. +# Requested path is in $1, any other request data is in proc/$proc/request. +# Usually you want to dispatch the path here and call some other programs. =) +# Path has ending / and no starting one (apth for root is empty). +# Response meta should be formed in proc/$proc/response, +# output is response body. +after () { test -z "${2##*$1*}" && echo -n "${2#*$1}"; } +startswith() { case $2 in "$1"*) true;; *) false;; esac; } +if test -z "$1" +then cat index.html +elif startswith "article/" "$1" +then cd article; ./entry "$(after / $1)" +elif startswith "admin/" "$1" +then cd admin; ./entry "$(after / $1)" +else cat 404.html +fi -- cgit v1.2.3