package handlers import ( "net/http" "github.com/pkg/errors" "git.haelnorr.com/h/golib/hws" "git.haelnorr.com/h/oslstats/internal/notify" "git.haelnorr.com/h/oslstats/internal/view/page" ) // NotifyTester handles responses to the / path. Also serves a 404 Page for paths that // don't have explicit handlers func NotifyTester(s *hws.Server) http.Handler { return http.HandlerFunc( func(w http.ResponseWriter, r *http.Request) { testErr := errors.New("This is a stack trace. No really i swear. Just pretend ok? Thanks") if r.Method == "GET" { renderSafely(page.Test(), s, r, w) } else { _ = r.ParseForm() // target := r.Form.Get("target") title := r.Form.Get("title") level := r.Form.Get("type") message := r.Form.Get("message") switch level { case "success": notify.Success(s, w, r, title, message, nil) case "info": notify.Info(s, w, r, title, message, nil) case "warn": notify.Warn(s, w, r, title, message, nil) case "error": notify.InternalServiceError(s, w, r, message, testErr) } } }, ) }