aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFuwn <[email protected]>2021-07-15 17:28:51 +0000
committerFuwn <[email protected]>2021-07-15 17:28:51 +0000
commit5bc41890df6b19e7b6c9d6214ec1d4370817087f (patch)
treea10be94b5542d4d159da5d9ec87e17575d91c769
parentMerge pull request #2 from fuwn/renovate/alpine-3.x (diff)
downloadspace-5bc41890df6b19e7b6c9d6214ec1d4370817087f.tar.xz
space-5bc41890df6b19e7b6c9d6214ec1d4370817087f.zip
fix(route): backup .gmi routing
-rw-r--r--route.go24
1 files changed, 8 insertions, 16 deletions
diff --git a/route.go b/route.go
index 4b1e694..4d5aacc 100644
--- a/route.go
+++ b/route.go
@@ -18,13 +18,14 @@ func createRoute(route string, template string, content string) {
Copyright: utilities.GetCopyright(),
})
})
- g.Handle(route+".gmi", func(c gig.Context) error {
- return c.Render(template, IndexTemplate{
- Content: GetContent(content),
- Quote: utilities.GetRandomQuote(),
- Hits: database.Get(route) + 1,
- Copyright: utilities.GetCopyright(),
- })
+
+ // Legacy support?
+ endString := ".gmi"
+ if route[len(route)-1:] == "/" {
+ endString = "index.gmi"
+ }
+ g.Handle(route+endString, func(c gig.Context) error {
+ return c.NoContent(gig.StatusRedirectPermanent, route)
})
}
@@ -38,15 +39,6 @@ func createErrorRoute(route string, template string, content string, err string)
Copyright: utilities.GetCopyright(),
})
})
- g.Handle(route+".gmi", func(c gig.Context) error {
- return c.Render(template, ErrorTemplate{
- Error: err,
- Content: GetContent(content),
- Quote: utilities.GetRandomQuote(),
- Hits: database.Get(route) + 1,
- Copyright: utilities.GetCopyright(),
- })
- })
}
func createFileRoute(route string, file string) {