diff options
| author | Fuwn <[email protected]> | 2021-07-14 21:46:15 +0000 |
|---|---|---|
| committer | Fuwn <[email protected]> | 2021-07-14 21:46:15 +0000 |
| commit | 80c553eb058fab6083d575559267fa4d8472727a (patch) | |
| tree | 569d92a85ea0b608bb6634ac1c31fc1c3c5b85a7 /route.go | |
| download | space-80c553eb058fab6083d575559267fa4d8472727a.tar.xz space-80c553eb058fab6083d575559267fa4d8472727a.zip | |
feat(space): :gemini:
Diffstat (limited to 'route.go')
| -rw-r--r-- | route.go | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/route.go b/route.go new file mode 100644 index 0000000..a30ef68 --- /dev/null +++ b/route.go @@ -0,0 +1,38 @@ +// Copyright (C) 2021-2021 Fuwn +// SPDX-License-Identifier: GPL-3.0-only + +package main + +import ( + "github.com/fuwn/space/pkg/utilities" + "github.com/pitr/gig" +) + +func createRoute(route string, template string, content string) { + g.Handle(route, func(c gig.Context) error { + return c.Render(template, IndexTemplate{ + Content: GetContent(content), + Quote: utilities.GetRandomQuote(), + Hits: hitsTracker[route] + 1, + Copyright: utilities.GetCopyright(), + }) + }) +} + +func createErrorRoute(route string, template string, content string, err string) { + g.Handle(route, func(c gig.Context) error { + return c.Render(template, ErrorTemplate{ + Error: err, + Content: GetContent(content), + Quote: utilities.GetRandomQuote(), + Hits: hitsTracker[route] + 1, + Copyright: utilities.GetCopyright(), + }) + }) +} + +func createFileRoute(route string, file string) { + g.Handle(route, func(c gig.Context) error { + return c.Text(GetContent(file)) + }) +} |