Shorten url param
This commit is contained in:
6
main.go
6
main.go
@@ -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",
|
||||||
},
|
},
|
||||||
|
|||||||
@@ -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>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user