mirror of
https://github.com/lone-cloud/prism
synced 2026-06-03 08:43:10 -07:00
18 lines
350 B
Go
18 lines
350 B
Go
package util
|
|
|
|
import (
|
|
"encoding/json"
|
|
"net/http"
|
|
)
|
|
|
|
func SetToast(w http.ResponseWriter, message, toastType string) {
|
|
trigger := map[string]interface{}{
|
|
"showToast": map[string]string{
|
|
"message": message,
|
|
"type": toastType,
|
|
},
|
|
}
|
|
if data, err := json.Marshal(trigger); err == nil {
|
|
w.Header().Set("HX-Trigger", string(data))
|
|
}
|
|
}
|