mirror of
https://github.com/mentos1386/zdravko.git
synced 2024-11-30 03:01:17 +00:00
34 lines
689 B
Go
34 lines
689 B
Go
|
package handlers
|
||
|
|
||
|
import (
|
||
|
"fmt"
|
||
|
"net/http"
|
||
|
"text/template"
|
||
|
|
||
|
"code.tjo.space/mentos1386/zdravko/web/templates"
|
||
|
"code.tjo.space/mentos1386/zdravko/web/templates/components"
|
||
|
)
|
||
|
|
||
|
func (h *BaseHandler) Error404(w http.ResponseWriter, r *http.Request) {
|
||
|
ts, err := template.ParseFS(templates.Templates,
|
||
|
"components/base.tmpl",
|
||
|
"pages/404.tmpl",
|
||
|
)
|
||
|
if err != nil {
|
||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||
|
return
|
||
|
}
|
||
|
|
||
|
w.WriteHeader(http.StatusNotFound)
|
||
|
|
||
|
err = ts.ExecuteTemplate(w, "base", &components.Base{
|
||
|
Page: nil,
|
||
|
Pages: Pages,
|
||
|
})
|
||
|
if err != nil {
|
||
|
fmt.Println("Error", err)
|
||
|
http.Error(w, err.Error(), http.StatusInternalServerError)
|
||
|
return
|
||
|
}
|
||
|
}
|