~nromdotcom/gemif

ref: 1bf434089d4531dcf6ce4735f644d52949571b1c gemif/pkg/web/router.go -rw-r--r-- 775 bytes
1bf43408Norm MacLennan First pass at conditionals 1 year, 1 month ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package web

import (
	"fmt"
	"gemif/pkg/gamemanager"
	"gemif/pkg/scenerenderer"
	"os"

	"github.com/markbates/pkger"
	"github.com/pitr/gig"
)

// StartRouter starts the gig server for handling Gemini requests.
func StartRouter(gm *gamemanager.GameManager) {
	//https://github.com/golangci/golangci-lint/issues/741
	//nolint:staticcheck
	pkger.Include("/static")

	tmpl, err := compileTemplates()
	if err != nil {
		fmt.Printf("Couldn't compile templates: %s", err)
		os.Exit(1)
	}

	sceneRenderer := scenerenderer.New()

	g := gig.Default()
	g.HideBanner = true
	g.Renderer = &Template{
		templates: tmpl,
	}

	g.Handle("/", handleHome(gm))
	g.Handle("/game/:statetoken", handleGame(gm, sceneRenderer))
	g.Handle("/docs*", handleStatic)

	panic(g.Run("my.crt", "my.key"))
}