summaryrefslogtreecommitdiff
path: root/contrib/cgi
diff options
context:
space:
mode:
authortjpcc <tjp@ctrl-c.club>2023-01-17 15:59:29 -0700
committertjpcc <tjp@ctrl-c.club>2023-01-17 15:59:29 -0700
commit2ef530daa47b301a40c1ee93cd43b8f36fc68c0b (patch)
treeb9753719f5f0e5312bb5008d40f40247ce14e15a /contrib/cgi
parent30e21f8513d49661cb6e1583d301e34e898d48a9 (diff)
pull request, response, handlers out of the gemini package
Diffstat (limited to 'contrib/cgi')
-rw-r--r--contrib/cgi/cgi.go15
1 files changed, 8 insertions, 7 deletions
diff --git a/contrib/cgi/cgi.go b/contrib/cgi/cgi.go
index e43f1ef..7f88e57 100644
--- a/contrib/cgi/cgi.go
+++ b/contrib/cgi/cgi.go
@@ -13,6 +13,7 @@ import (
"os/exec"
"strings"
+ "tildegit.org/tjp/gus"
"tildegit.org/tjp/gus/gemini"
)
@@ -22,12 +23,12 @@ import (
// a request for /foo/bar/baz can also run an executable found at /foo or /foo/bar. In
// such a case the PATH_INFO environment variable will include the remaining portion of
// the URI path.
-func CGIDirectory(pathRoot, fsRoot string) gemini.Handler {
+func CGIDirectory(pathRoot, fsRoot string) gus.Handler {
fsRoot = strings.TrimRight(fsRoot, "/")
- return func(ctx context.Context, req *gemini.Request) *gemini.Response {
+ return func(ctx context.Context, req *gus.Request) *gus.Response {
if !strings.HasPrefix(req.Path, pathRoot) {
- return gemini.NotFound("Resource does not exist.")
+ return nil
}
path := req.Path[len(pathRoot):]
@@ -53,7 +54,7 @@ func CGIDirectory(pathRoot, fsRoot string) gemini.Handler {
}
}
- return gemini.NotFound("Resource does not exist.")
+ return nil
}
}
@@ -97,10 +98,10 @@ func isNotExistError(err error) bool {
// RunCGI runs a specific program as a CGI script.
func RunCGI(
ctx context.Context,
- req *gemini.Request,
+ req *gus.Request,
executable string,
pathInfo string,
-) *gemini.Response {
+) *gus.Response {
pathSegments := strings.Split(executable, "/")
dirPath := "."
@@ -139,7 +140,7 @@ func RunCGI(
func prepareCGIEnv(
ctx context.Context,
- req *gemini.Request,
+ req *gus.Request,
scriptName string,
pathInfo string,
) []string {