layout refact

This commit is contained in:
2026-01-29 20:47:18 +01:00
parent 44700d51cb
commit 27131b3029
10 changed files with 150 additions and 55 deletions
+15 -4
View File
@@ -8,14 +8,25 @@ import (
)
type RootController struct {
service domain.SoftwareServiceInterface
softwareService domain.SoftwareServiceInterface
}
func NewRootController() *RootController {
return &RootController{}
func NewRootController(softwareService domain.SoftwareServiceInterface) *RootController {
return &RootController{
softwareService: softwareService,
}
}
func (c *RootController) Index(w http.ResponseWriter, r *http.Request) {
softwares, err := c.softwareService.List()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
data := map[string]interface{}{
"Softwares": softwares,
}
tmpl, err := template_utils.GetTemplate("root_index", "http/views/shared/layout.html", "http/views/root/index.html")
if err != nil {
@@ -23,5 +34,5 @@ func (c *RootController) Index(w http.ResponseWriter, r *http.Request) {
return
}
tmpl.Execute(w, nil)
tmpl.Execute(w, data)
}