aboutsummaryrefslogtreecommitdiff
path: root/pkg/handler/git.go
blob: 1ed2c49d357ffbb4b74f2a2331cd84fd6a660794 (plain)
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
package handler

import (
	"log/slog"
	"net/http"

	"git.gabrielgio.me/cerrado/pkg/service"
	"git.gabrielgio.me/cerrado/templates"
)

type GitHandler struct {
	gitService *service.GitService
}

func NewGitHandler(gitService *service.GitService) *GitHandler {
	return &GitHandler{gitService}
}

func (g *GitHandler) List(w http.ResponseWriter, _ *http.Request) {
	repos, err := g.gitService.ListRepositories()
	if err != nil {
		slog.Error("Error listing repo", "error", err)
		return
	}

	gitList := &templates.GitListPage{repos}
	templates.WritePageTemplate(w, gitList)
}