blob: e0887497dfa2ec7d9284384ca6fcfc949b8609ca (
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
37
38
39
40
41
|
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)
}
func (g *GitHandler) Item(w http.ResponseWriter, _ *http.Request) {
gitList := &templates.GitItemPage{}
templates.WritePageTemplate(w, gitList)
}
|