summaryrefslogtreecommitdiff
path: root/routes.go
diff options
context:
space:
mode:
Diffstat (limited to 'routes.go')
-rw-r--r--routes.go26
1 files changed, 16 insertions, 10 deletions
diff --git a/routes.go b/routes.go
index 9c330b6..08d2c56 100644
--- a/routes.go
+++ b/routes.go
@@ -6,6 +6,7 @@ import (
"crypto/x509"
"encoding/hex"
"os"
+ "path/filepath"
"sort"
"strings"
@@ -15,7 +16,8 @@ import (
"tildegit.org/tjp/sliderule/contrib/tlsauth"
"tildegit.org/tjp/sliderule/finger"
"tildegit.org/tjp/sliderule/gemini"
- "tildegit.org/tjp/sliderule/gemini/gemtext"
+ "tildegit.org/tjp/sliderule/gemini/gemtext/atomconv"
+ "tildegit.org/tjp/sliderule/gopher/gophermap"
"tildegit.org/tjp/sliderule/logging"
)
@@ -58,32 +60,36 @@ func geminiRouter(conf config) sr.Handler {
h := router.Handler()
if conf.geminiAutoAtom {
- h = gemtext.AutoAtom(h)
+ h = atomconv.Auto(h)
}
return h
}
func gopherRouter(conf config) sr.Handler {
- fsys := os.DirFS(conf.gopherRoot)
+ settings := gophermap.FileSystemSettings{
+ ParseExtended: true,
+ Exec: true,
+ ListUsers: false,
+ DirMaps: []string{"gophermap"},
+ DirTag: "gophertag",
+ }
router := &sr.Router{}
router.Route(
"/*",
sr.FallthroughHandler(
- fs.GopherFileHandler(fsys),
- fs.GopherDirectoryDefault(fsys, "index.gophermap"),
- fs.GopherDirectoryListing(fsys, nil),
+ cgi.ExecGopherMaps("/", conf.gopherRoot, &settings),
+ fs.GopherFileHandler(conf.gopherRoot, &settings),
+ fs.GopherDirectoryDefault(conf.gopherRoot, &settings),
+ fs.GopherDirectoryListing(conf.gopherRoot, &settings),
),
)
router.Route(
"/cgi-bin/*",
- cgi.GopherCGIDirectory(
- "/cgi-bin/",
- strings.Join([]string{".", strings.Trim(conf.gopherRoot, "/"), "cgi-bin"}, "/"),
- ),
+ cgi.GopherCGIDirectory("/cgi-bin/", filepath.Join(conf.gopherRoot, "cgi-bin"), &settings),
)
return router.Handler()