cerrado @ fb45f1f5002ffdb40150333c5a48458b801f3022

 1package git
 2
 3import (
 4	"log/slog"
 5	"net/http"
 6
 7	"git.gabrielgio.me/cerrado/pkg/service"
 8	"git.gabrielgio.me/cerrado/templates"
 9)
10
11type (
12	GitHandler struct {
13		gitService gitService
14	}
15
16	gitService interface {
17		ListRepositories() ([]*service.Repository, error)
18	}
19)
20
21func NewGitHandler(gitService gitService) *GitHandler {
22	return &GitHandler{
23		gitService: gitService,
24	}
25}
26
27func (g *GitHandler) List(w http.ResponseWriter, _ *http.Request) {
28	repos, err := g.gitService.ListRepositories()
29	if err != nil {
30		slog.Error("Error listing repo", "error", err)
31		return
32	}
33
34	gitList := &templates.GitListPage{repos}
35	templates.WritePageTemplate(w, gitList)
36}
37
38func (g *GitHandler) Item(w http.ResponseWriter, _ *http.Request) {
39	gitList := &templates.GitItemPage{}
40	templates.WritePageTemplate(w, gitList)
41}