blob: 236ac414a2ce8afb92d6c86bc64781a7f8189904 (
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
29
30
31
32
33
34
35
36
|
package git
import (
"log/slog"
"net/http"
"git.gabrielgio.me/cerrado/pkg/service"
"git.gabrielgio.me/cerrado/templates"
)
type (
GitHandler struct {
gitService gitService
}
gitService interface {
ListRepositories() ([]*service.Repository, error)
}
)
func NewGitHandler(gitService gitService) *GitHandler {
return &GitHandler{
gitService: 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)
}
|