summaryrefslogtreecommitdiff
path: root/contrib/cgi
diff options
context:
space:
mode:
Diffstat (limited to 'contrib/cgi')
-rw-r--r--contrib/cgi/gopher.go11
1 files changed, 7 insertions, 4 deletions
diff --git a/contrib/cgi/gopher.go b/contrib/cgi/gopher.go
index 98a3c75..67ea688 100644
--- a/contrib/cgi/gopher.go
+++ b/contrib/cgi/gopher.go
@@ -34,7 +34,9 @@ func GopherCGIDirectory(pathRoot, fsRoot string, settings *gophermap.FileSystemS
return nil
}
- fullpath, pathinfo, err := resolveGopherCGI(fsRoot, request)
+ requestPath := strings.Trim(strings.TrimPrefix(request.Path, pathRoot), "/")
+
+ fullpath, pathinfo, err := resolveGopherCGI(fsRoot, requestPath)
if err != nil {
return gopher.Error(err).Response()
}
@@ -128,15 +130,16 @@ func runGopherCGI(
}
doc, _, err := edoc.Compatible(filepath.Dir(fullpath), settings)
+ if err != nil {
+ return gopher.Error(err).Response()
+ }
return doc.Response()
}
return gopher.File(gopher.MenuType, stdout)
}
-func resolveGopherCGI(fsRoot string, request *sr.Request) (string, string, error) {
- reqPath := strings.TrimLeft(request.Path, "/")
-
+func resolveGopherCGI(fsRoot string, reqPath string) (string, string, error) {
segments := append([]string{""}, strings.Split(reqPath, "/")...)
fullpath := fsRoot
for i, segment := range segments {