feat: pretty shitty code
This commit is contained in:
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user