we now got websockets baby

This commit is contained in:
2026-01-26 00:29:57 +11:00
parent 959ca96b68
commit 0ae4ebccfc
23 changed files with 620 additions and 311 deletions

View File

@@ -7,6 +7,7 @@ import (
"github.com/pkg/errors"
"git.haelnorr.com/h/golib/hws"
"git.haelnorr.com/h/golib/notify"
)
// Handles responses to the / path. Also serves a 404 Page for paths that
@@ -18,25 +19,33 @@ func Test(server *hws.Server) http.Handler {
page.Test().Render(r.Context(), w)
} else {
r.ParseForm()
notifytype := r.Form.Get("type")
target := r.Form.Get("target")
title := r.Form.Get("title")
level := map[string]notify.Level{
"info": notify.LevelInfo,
"success": notify.LevelSuccess,
"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")
switch notifytype {
case "error":
err := errors.New(message)
notifyInternalServiceError(server, w, title, err)
return
case "warn":
notifyWarning(w, title, message)
return
case "info":
notifyInfo(w, title, message)
return
case "success":
notifySuccess(w, title, message)
return
nt := notify.Notification{
Target: notify.Target(target),
Title: title,
Message: message,
Level: level,
Details: error.Error(),
}
if target == "" {
server.NotifyAll(nt)
} else {
server.NotifySub(nt)
}
}
},
)
}
func notifyInfoWS() {
}