feat: pretty shitty code

This commit is contained in:
2024-11-20 20:18:45 -05:00
parent 91741b38a1
commit 3eeb4c8b48
9 changed files with 269 additions and 3 deletions

View File

@@ -44,6 +44,22 @@ func (h *handler) RequestsCounterMiddleware(next http.Handler) http.Handler {
func (h *handler) Ping(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, "Pong")
}
func (h *handler) Index(w http.ResponseWriter, r *http.Request) {
h.logger.Info(r.URL.Path)
if template, isOk := templates[r.URL.Path]; isOk {
h.logger.Info("Found template")
template.ExecuteTemplate(w, "base", nil)
} else {
h.logger.Info("default template")
templates["index.html"].ExecuteTemplate(w, "base", nil)
}
}
func (h *handler) FileServer(w http.ResponseWriter, r *http.Request) {
h.logger.Info("handled by file server router")
http.FileServer(http.FS(staticContent)).ServeHTTP(w, r)
}
func (h *handler) Metrics(w http.ResponseWriter, r *http.Request) {
h.requestsCounter.mu.Lock()