all repos

mugit @ b407568d0a3ac5a14ba9b93f349903d11e7c224d

🐮 git server that your cow will love

mugit/internal/handlers/handles.go(view raw)

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
package handlers

import (
	"html/template"
	"net/http"
	"path/filepath"

	"olexsmir.xyz/mugit/internal/config"
)

type handlers struct {
	c *config.Config
	t *template.Template
}

func InitRoutes(cfg *config.Config) *http.ServeMux {
	tmpls := template.Must(template.ParseGlob(
		filepath.Join(cfg.Meta.TemplatesDir, "*"),
	))
	h := handlers{cfg, tmpls}

	mux := http.NewServeMux()
	mux.HandleFunc("GET /", h.index)

	return mux
}