package handler

import (
	"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) {
	gitList := &templates.GitListPage{g.gitService.ListRepositories()}
	templates.WritePageTemplate(w, gitList)
}