iAdd REST handling example to manpage. - geomyidae - A small C-based gopherd. Err bitreich.org 70 hgit clone git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ URL:git://bitreich.org/geomyidae/ git://enlrupgkhuxnvlhsf6lc3fziv5h2hhfrinws65d7roiv6bfj7d652fid.onion/geomyidae/ bitreich.org 70 1Log /scm/geomyidae/log.gph bitreich.org 70 1Files /scm/geomyidae/files.gph bitreich.org 70 1Refs /scm/geomyidae/refs.gph bitreich.org 70 1Tags /scm/geomyidae/tag bitreich.org 70 1README /scm/geomyidae/file/README.gph bitreich.org 70 1LICENSE /scm/geomyidae/file/LICENSE.gph bitreich.org 70 i--- Err bitreich.org 70 1commit 28c6362fb2bcbe837e46883e60eb2e89efc59692 /scm/geomyidae/commit/28c6362fb2bcbe837e46883e60eb2e89efc59692.gph bitreich.org 70 1parent 81f3ec7d02246ab56d7fcc57ce18d546a3fe4b6f /scm/geomyidae/commit/81f3ec7d02246ab56d7fcc57ce18d546a3fe4b6f.gph bitreich.org 70 hAuthor: Christoph Lohmann <20h@r-36.net> URL:mailto:20h@r-36.net bitreich.org 70 iDate: Sat, 22 Jul 2023 17:51:54 +0200 Err bitreich.org 70 i Err bitreich.org 70 iAdd REST handling example to manpage. Err bitreich.org 70 i Err bitreich.org 70 iDiffstat: Err bitreich.org 70 i M geomyidae.8 | 45 ++++++++++++++++++++++++------- Err bitreich.org 70 i M handlr.c | 2 -- Err bitreich.org 70 i Err bitreich.org 70 i2 files changed, 35 insertions(+), 12 deletions(-) Err bitreich.org 70 i--- Err bitreich.org 70 1diff --git a/geomyidae.8 b/geomyidae.8 /scm/geomyidae/file/geomyidae.8.gph bitreich.org 70 i@@ -331,22 +331,28 @@ Search Veronica II Err bitreich.org 70 i Telnet to SDF Public Access Unix System Err bitreich.org 70 i .El Err bitreich.org 70 i .Sh DYNAMIC CONTENT (gopher CGI) Err bitreich.org 70 i-There are two options provided for dynamic content creation: standard CGI ( Err bitreich.org 70 i+There are two options provided for dynamic content creation and a special Err bitreich.org 70 i+case: standard CGI ( Err bitreich.org 70 i .Ic .cgi Err bitreich.org 70 i-) and dynamic CGI Err bitreich.org 70 i+), dynamic CGI Err bitreich.org 70 i ( Err bitreich.org 70 i .Ic .dcgi Err bitreich.org 70 i-). Despite the names, both can accept input and generate dynamic content; Err bitreich.org 70 i-the only difference is the latter re-formats it's output so it appears to Err bitreich.org 70 i+) and http compatibility mode. Err bitreich.org 70 i+Despite the names, all three can accept input and generate dynamic content; Err bitreich.org 70 i+the only difference is that dcgi re-formats it's output so it appears to Err bitreich.org 70 i the server as a standard geomyidae index (.gph) file. This makes the Err bitreich.org 70 i creation of on-the-fly gopher directories much easier (see examples). Err bitreich.org 70 i All scripts must be under the gopher root directory and be executable by Err bitreich.org 70 i the same user:group running geomyidae. Consequently, it is best to use Err bitreich.org 70 i the -u and -g server options to avoid running as root. Err bitreich.org 70 i .Pp Err bitreich.org 70 i+Executed scripts get the full I/O of the socket bound to stdin and stdout. You Err bitreich.org 70 i+are thus able to write long-lasting streaming services. Radio or TV stations over Err bitreich.org 70 i+gopher are possible that way. Err bitreich.org 70 i+.Pp Err bitreich.org 70 i Both .cgi and .dcgi scripts have the same argument call structure (as seen by geomyidae): Err bitreich.org 70 i .Bd -literal -offset indent Err bitreich.org 70 i-executable.[d]cgi $search $arguments $host $port Err bitreich.org 70 i+executable.[d]cgi $search $arguments $host $port $traversal $selector Err bitreich.org 70 i .Ed Err bitreich.org 70 i .Pp Err bitreich.org 70 i where Err bitreich.org 70 i@@ -355,8 +361,8 @@ search = query string (type 7) or "" (type 0) Err bitreich.org 70 i arguments = string behind "?" in selector or "" Err bitreich.org 70 i host = server's hostname ("localhost" by default) Err bitreich.org 70 i port = server's port ("70" by default) Err bitreich.org 70 i-traversal = remaining path from path traversal Err bitreich.org 70 i-selector = raw selector Err bitreich.org 70 i+traversal = remaining path from path traversal in REST case Err bitreich.org 70 i+selector = raw selector or full req (See http compatibility mode.) Err bitreich.org 70 i .Ed Err bitreich.org 70 i .Pp Err bitreich.org 70 i All terms are tab-separated (per gopher protocol) which can cause some Err bitreich.org 70 i@@ -381,7 +387,7 @@ PATH_TRANSLATED = absolute path with script which is executed Err bitreich.org 70 i QUERY_STRING = arguments (See above.) Err bitreich.org 70 i SELECTOR = raw selector Err bitreich.org 70 i REQUEST = raw selector Err bitreich.org 70 i-TRAVERSAL = traversel (See above.) Err bitreich.org 70 i+TRAVERSAL = traversal (See above.) Err bitreich.org 70 i REMOTE_ADDR = IP of the client Err bitreich.org 70 i REMOTE_HOST = REMOTE_ADDR Err bitreich.org 70 i REQUEST_METHOD = `GET' Err bitreich.org 70 i@@ -396,6 +402,23 @@ SEARCHREQUEST = search (For backwards compatibility.) Err bitreich.org 70 i HTTPS and GOPHERS = set, if TLS is used Err bitreich.org 70 i .Ed Err bitreich.org 70 i . Err bitreich.org 70 i+.Ss The REST path handling Err bitreich.org 70 i+If a client requests a path in a selector, which has no corresponding Err bitreich.org 70 i+file or path found, geomyidae will try to traverse from the Err bitreich.org 70 i+.Fl b Ar base Err bitreich.org 70 i+path until a path component / directory is not found. Then geomyidae Err bitreich.org 70 i+tries to find some index.dcgi or index.cgi file in the last existing Err bitreich.org 70 i+directory. If this is found and the index files are executable, geomyidae Err bitreich.org 70 i+will execute them using the traversal and TRAVERSAL parameter and Err bitreich.org 70 i+environment variable being set to the rest path. Err bitreich.org 70 i+.Bd -literal -offset indent Err bitreich.org 70 i+Selector: /some/v1/service/add/something?args=value Err bitreich.org 70 i+-> /some/v1/service exists Err bitreich.org 70 i+-> /some/v1/service/index.dcgi exists Err bitreich.org 70 i+-> /some/v1/service/index.dcgi "" "args=value" $host $port Err bitreich.org 70 i+"/add/something" "/some/v1/service/add/something?args=value" is called Err bitreich.org 70 i+.Ed Err bitreich.org 70 i+. Err bitreich.org 70 i .Ss Some CGI Examples Err bitreich.org 70 i Note: these are a very simple examples with no fitness checks with respect Err bitreich.org 70 i to safety/security. Err bitreich.org 70 i@@ -490,9 +513,11 @@ Phrases_of_the_Ages.txt Err bitreich.org 70 i Care should to be exercised to avoid creating miss-Typed entries, unwanted Err bitreich.org 70 i recursions, and/or unintended writes in the working directory. Err bitreich.org 70 i .Sh HAPROXY SUPPORT Err bitreich.org 70 i-Geomyidae has Err bitreich.org 70 i+geomyidae has Err bitreich.org 70 i .Em HAProxy Err bitreich.org 70 i-support. It can be enabled using the -y parameter. Err bitreich.org 70 i+support. It can be enabled using the Err bitreich.org 70 i+.Fl y Err bitreich.org 70 i+parameter. Err bitreich.org 70 i . Err bitreich.org 70 i .Sh LOG FILES Err bitreich.org 70 i The log file (ie. /var/log/gopherd.log) has the following structure: Err bitreich.org 70 1diff --git a/handlr.c b/handlr.c /scm/geomyidae/file/handlr.c.gph bitreich.org 70 i@@ -159,8 +159,6 @@ handlecgi(int sock, char *file, char *port, char *base, char *args, Err bitreich.org 70 i filec = xstrdup(file); Err bitreich.org 70 i path = dirname(filec); Err bitreich.org 70 i script = path + strlen(path) + 1; Err bitreich.org 70 i- printf("path = %s\n", path); Err bitreich.org 70 i- printf("script = %s\n", script); Err bitreich.org 70 i Err bitreich.org 70 i if (sear == NULL) Err bitreich.org 70 i sear = ""; Err bitreich.org 70 .