Shorten url param

This commit is contained in:
Ian Gulliver
2024-11-23 06:35:38 -08:00
parent e5ad2059a0
commit d6be7a5d2c
2 changed files with 7 additions and 7 deletions

View File

@@ -56,8 +56,8 @@ func (ph *PHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
log.Printf("%s %s", r.RemoteAddr, r.Form.Encode()) log.Printf("%s %s", r.RemoteAddr, r.Form.Encode())
msg := r.Form.Get("msg") m := r.Form.Get("m")
if msg == "" { if m == "" {
err = ph.tmpl.Execute(w, ph.envs()) err = ph.tmpl.Execute(w, ph.envs())
if err != nil { if err != nil {
http.Error(w, fmt.Sprintf("execute %s: %s\n", ph.tmpl.Name(), err), http.StatusBadRequest) http.Error(w, fmt.Sprintf("execute %s: %s\n", ph.tmpl.Name(), err), http.StatusBadRequest)
@@ -72,7 +72,7 @@ func (ph *PHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
RoutingKey: ph.routingKey, RoutingKey: ph.routingKey,
EventAction: "trigger", EventAction: "trigger",
Payload: PDPayload{ Payload: PDPayload{
Summary: msg, Summary: m,
Source: r.RemoteAddr, Source: r.RemoteAddr,
Severity: "critical", Severity: "critical",
}, },

View File

@@ -61,9 +61,9 @@ function error(err1, err2) {
} }
async function page() { async function page() {
const msg = document.getElementById('message').value; const m = document.getElementById('message').value;
if (msg == '') { if (m == '') {
error('Please fill in Message', ''); error('Please fill in Message', '');
return; return;
} }
@@ -71,7 +71,7 @@ async function page() {
clearAlerts(); clearAlerts();
const params = new URLSearchParams({ const params = new URLSearchParams({
msg: msg, m: m,
}); });
const resp = await fetch( const resp = await fetch(
@@ -189,7 +189,7 @@ async function page() {
<span id="curl"></span> <span id="curl"></span>
<sl-copy-button from="curl"></sl-copy-button> <sl-copy-button from="curl"></sl-copy-button>
<script> <script>
document.getElementById('curl').innerText = `curl -d 'msg=test' ${window.location.href}`; document.getElementById('curl').innerText = `curl -d 'm=test' ${window.location.href}`;
</script> </script>
</div> </div>