diff options
| author | Fuwn <[email protected]> | 2021-07-15 17:28:51 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-15 17:28:51 +0000 |
| commit | 5bc41890df6b19e7b6c9d6214ec1d4370817087f (patch) | |
| tree | a10be94b5542d4d159da5d9ec87e17575d91c769 | |
| parent | Merge pull request #2 from fuwn/renovate/alpine-3.x (diff) | |
| download | space-5bc41890df6b19e7b6c9d6214ec1d4370817087f.tar.xz space-5bc41890df6b19e7b6c9d6214ec1d4370817087f.zip | |
fix(route): backup .gmi routing
| -rw-r--r-- | route.go | 24 |
1 files changed, 8 insertions, 16 deletions
@@ -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) { |