error modals are so on
This commit is contained in:
@@ -3,11 +3,11 @@ package handlers
|
||||
import (
|
||||
"net/http"
|
||||
|
||||
"git.haelnorr.com/h/oslstats/internal/view/page"
|
||||
"github.com/pkg/errors"
|
||||
|
||||
"git.haelnorr.com/h/golib/hws"
|
||||
"git.haelnorr.com/h/golib/notify"
|
||||
"git.haelnorr.com/h/oslstats/internal/view/page"
|
||||
)
|
||||
|
||||
// Handles responses to the / path. Also serves a 404 Page for paths that
|
||||
@@ -15,7 +15,14 @@ import (
|
||||
func NotifyTester(server *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" {
|
||||
// page, _ := ErrorPage(hws.HWSError{
|
||||
// StatusCode: http.StatusTeapot,
|
||||
// Message: "This error has been rendered as a test",
|
||||
// Error: testErr,
|
||||
// })
|
||||
// page.Render(r.Context(), w)
|
||||
page.Test().Render(r.Context(), w)
|
||||
} else {
|
||||
r.ParseForm()
|
||||
@@ -27,16 +34,20 @@ func NotifyTester(server *hws.Server) http.Handler {
|
||||
"warn": notify.LevelWarn,
|
||||
"error": notify.LevelError,
|
||||
}[r.Form.Get("type")]
|
||||
error := errors.New("This is a stack trace. No really i swear. Just pretend ok? Thanks")
|
||||
message := r.Form.Get("message")
|
||||
nt := notify.Notification{
|
||||
Target: notify.Target(target),
|
||||
Title: title,
|
||||
Message: message,
|
||||
Level: level,
|
||||
Details: error.Error(),
|
||||
}
|
||||
if target == "" {
|
||||
|
||||
// For error level, serialize error details with code
|
||||
if level == notify.LevelError {
|
||||
nt.Details = SerializeErrorDetails(500, testErr)
|
||||
}
|
||||
|
||||
if target == "all" {
|
||||
server.NotifyAll(nt)
|
||||
} else {
|
||||
server.NotifySub(nt)
|
||||
@@ -45,7 +56,3 @@ func NotifyTester(server *hws.Server) http.Handler {
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
func notifyInfoWS() {
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user