2024-08-27 19:24:24 +00:00
|
|
|
{{template "base" .}}
|
|
|
|
|
|
|
|
{{define "content" }}
|
|
|
|
<div class="container">
|
|
|
|
<div class="row">
|
|
|
|
<div class="col">
|
|
|
|
<h1 class="mt-5">Test microservices</h1>
|
|
|
|
<hr>
|
|
|
|
|
2024-08-28 07:49:39 +00:00
|
|
|
<a id="brokerBtn" class="btn btn-outline-secondary" href="javascript:void(0);">Test Broker</a>
|
2024-08-28 19:51:51 +00:00
|
|
|
<a id="authBrokerBtn" class="btn btn-outline-secondary" href="javascript:void(0);">Test Auth</a>
|
2024-09-06 19:00:08 +00:00
|
|
|
<a id="logHttpBtn" class="btn btn-outline-secondary" href="javascript:void(0);">Test HTTP Log</a>
|
|
|
|
<a id="logRabbitBtn" class="btn btn-outline-secondary" href="javascript:void(0);">Test Rabbit Log</a>
|
|
|
|
<a id="logRpcBtn" class="btn btn-outline-secondary" href="javascript:void(0);">Test RPC Log</a>
|
2024-09-06 21:11:49 +00:00
|
|
|
<a id="logGrpcBtn" class="btn btn-outline-secondary" href="javascript:void(0);">Test gRPC Log</a>
|
2024-09-02 19:32:59 +00:00
|
|
|
<a id="mailBtn" class="btn btn-outline-secondary" href="javascript:void(0);">Test Mail</a>
|
2024-08-28 07:49:39 +00:00
|
|
|
|
2024-08-27 19:24:24 +00:00
|
|
|
<div id="output" class="mt-5" style="outline: 1px solid silver; padding: 2em;">
|
|
|
|
<span class="text-muted">Output shows here...</span>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="row">
|
|
|
|
<div class="col">
|
|
|
|
<h4 class="mt-5">Sent</h4>
|
|
|
|
<div class="mt-1" style="outline: 1px solid silver; padding: 2em;">
|
|
|
|
<pre id="payload"><span class="text-muted">Nothing sent yet...</span></pre>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
<div class="col">
|
|
|
|
<h4 class="mt-5">Received</h4>
|
|
|
|
<div class="mt-1" style="outline: 1px solid silver; padding: 2em;">
|
|
|
|
<pre id="received"><span class="text-muted">Nothing received yet...</span></pre>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
</div>
|
|
|
|
{{end}}
|
|
|
|
|
|
|
|
{{define "js"}}
|
|
|
|
<script>
|
2024-08-28 07:49:39 +00:00
|
|
|
let brokerBtn = document.getElementById("brokerBtn");
|
2024-08-28 19:51:51 +00:00
|
|
|
let authBrokerBtn = document.getElementById("authBrokerBtn");
|
2024-09-02 19:32:59 +00:00
|
|
|
let mailBtn = document.getElementById("mailBtn");
|
2024-09-06 19:00:08 +00:00
|
|
|
let logHttpBtn = document.getElementById("logHttpBtn");
|
|
|
|
let logRabbitBtn = document.getElementById("logRabbitBtn");
|
|
|
|
let logRpcBtn = document.getElementById("logRpcBtn");
|
2024-09-06 21:11:49 +00:00
|
|
|
let logGrpcBtn = document.getElementById("logGrpcBtn");
|
2024-08-28 07:49:39 +00:00
|
|
|
let output = document.getElementById("output");
|
|
|
|
let sent = document.getElementById("payload");
|
|
|
|
let received = document.getElementById("received");
|
|
|
|
|
|
|
|
brokerBtn.addEventListener("click", () => {
|
|
|
|
const body = {
|
|
|
|
method: 'POST',
|
|
|
|
}
|
|
|
|
fetch("http:\/\/localhost:8080", body)
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
sent.innerHTML = 'empty post request';
|
|
|
|
received.innerHTML = JSON.stringify(data, undefined, 4);
|
|
|
|
if (data.error) {
|
|
|
|
console.log(data.message);
|
|
|
|
} else {
|
|
|
|
output.innerHTML += `<br><strong>Response from broker service</strong>: ${data.message}`;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
output.innerHTML += "<br><br>Error: " + error;
|
|
|
|
});
|
|
|
|
});
|
2024-08-28 19:51:51 +00:00
|
|
|
|
|
|
|
authBrokerBtn.addEventListener("click", () => {
|
|
|
|
const payload = {
|
|
|
|
action: "auth",
|
|
|
|
auth: {
|
|
|
|
email: "admin@example.com",
|
|
|
|
password: "verysecret",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const headers = new Headers();
|
|
|
|
headers.append("Content-Type", "application/json");
|
|
|
|
const body = {
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
headers: headers,
|
|
|
|
}
|
|
|
|
fetch("http:\/\/localhost:8080/handle", body)
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
sent.innerHTML = JSON.stringify(payload, undefined, 4);
|
|
|
|
received.innerHTML = JSON.stringify(data, undefined, 4);
|
|
|
|
if (data.error) {
|
|
|
|
console.log(data.message);
|
|
|
|
output.innerHTML += `<br><strong>Error:</strong>: ${data.message}`;
|
|
|
|
} else {
|
|
|
|
output.innerHTML += `<br><strong>Response from broker service</strong>: ${data.message}`;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
output.innerHTML += "<br><br>Error: " + error;
|
|
|
|
});
|
|
|
|
});
|
2024-08-30 07:45:01 +00:00
|
|
|
|
2024-09-06 19:00:08 +00:00
|
|
|
logHttpBtn.addEventListener("click", () => {
|
2024-08-30 07:45:01 +00:00
|
|
|
const payload = {
|
2024-09-06 19:00:08 +00:00
|
|
|
action: "logHttp",
|
|
|
|
log: {
|
|
|
|
name: "event",
|
|
|
|
data: "some kind of data",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const headers = new Headers();
|
|
|
|
headers.append("Content-Type", "application/json");
|
|
|
|
const body = {
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
headers: headers,
|
|
|
|
}
|
|
|
|
fetch("http:\/\/localhost:8080/handle", body)
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
sent.innerHTML = JSON.stringify(payload, undefined, 4);
|
|
|
|
received.innerHTML = JSON.stringify(data, undefined, 4);
|
|
|
|
if (data.error) {
|
|
|
|
console.log(data.message);
|
|
|
|
output.innerHTML += `<br><strong>Error:</strong>: ${data.message}`;
|
|
|
|
} else {
|
|
|
|
output.innerHTML += `<br><strong>Response from broker service</strong>: ${data.message}`;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
output.innerHTML += "<br><br>Error: " + error;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
logRabbitBtn.addEventListener("click", () => {
|
|
|
|
const payload = {
|
|
|
|
action: "logRabbit",
|
|
|
|
log: {
|
|
|
|
name: "event",
|
|
|
|
data: "some kind of data",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const headers = new Headers();
|
|
|
|
headers.append("Content-Type", "application/json");
|
|
|
|
const body = {
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
headers: headers,
|
|
|
|
}
|
|
|
|
fetch("http:\/\/localhost:8080/handle", body)
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
sent.innerHTML = JSON.stringify(payload, undefined, 4);
|
|
|
|
received.innerHTML = JSON.stringify(data, undefined, 4);
|
|
|
|
if (data.error) {
|
|
|
|
console.log(data.message);
|
|
|
|
output.innerHTML += `<br><strong>Error:</strong>: ${data.message}`;
|
|
|
|
} else {
|
|
|
|
output.innerHTML += `<br><strong>Response from broker service</strong>: ${data.message}`;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
output.innerHTML += "<br><br>Error: " + error;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
logRpcBtn.addEventListener("click", () => {
|
|
|
|
const payload = {
|
|
|
|
action: "logRpc",
|
2024-08-30 07:45:01 +00:00
|
|
|
log: {
|
|
|
|
name: "event",
|
|
|
|
data: "some kind of data",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const headers = new Headers();
|
|
|
|
headers.append("Content-Type", "application/json");
|
2024-09-02 19:32:59 +00:00
|
|
|
const body = {
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
headers: headers,
|
|
|
|
}
|
|
|
|
fetch("http:\/\/localhost:8080/handle", body)
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
sent.innerHTML = JSON.stringify(payload, undefined, 4);
|
2024-09-06 21:11:49 +00:00
|
|
|
received.innerHTML = JSON.stringify(data, undefined, 4);
|
|
|
|
if (data.error) {
|
|
|
|
console.log(data.message);
|
|
|
|
output.innerHTML += `<br><strong>Error:</strong>: ${data.message}`;
|
|
|
|
} else {
|
|
|
|
output.innerHTML += `<br><strong>Response from broker service</strong>: ${data.message}`;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
output.innerHTML += "<br><br>Error: " + error;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
logGrpcBtn.addEventListener("click", () => {
|
|
|
|
const payload = {
|
|
|
|
action: "logGrpc",
|
|
|
|
log: {
|
|
|
|
name: "event",
|
|
|
|
data: "some kind of data",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const headers = new Headers();
|
|
|
|
headers.append("Content-Type", "application/json");
|
|
|
|
const body = {
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
headers: headers,
|
|
|
|
}
|
|
|
|
fetch("http:\/\/localhost:8080/handle", body)
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
sent.innerHTML = JSON.stringify(payload, undefined, 4);
|
2024-09-02 19:32:59 +00:00
|
|
|
received.innerHTML = JSON.stringify(data, undefined, 4);
|
|
|
|
if (data.error) {
|
|
|
|
console.log(data.message);
|
|
|
|
output.innerHTML += `<br><strong>Error:</strong>: ${data.message}`;
|
|
|
|
} else {
|
|
|
|
output.innerHTML += `<br><strong>Response from broker service</strong>: ${data.message}`;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
output.innerHTML += "<br><br>Error: " + error;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
mailBtn.addEventListener("click", () => {
|
|
|
|
const payload = {
|
|
|
|
action: "mail",
|
|
|
|
mail: {
|
|
|
|
from: "admin@example.com",
|
|
|
|
to: "me@here.com",
|
|
|
|
subject: "This is not a phishing mail",
|
|
|
|
content: "Send me money now!",
|
|
|
|
}
|
|
|
|
};
|
|
|
|
const headers = new Headers();
|
|
|
|
headers.append("Content-Type", "application/json");
|
2024-08-30 07:45:01 +00:00
|
|
|
const body = {
|
|
|
|
method: 'POST',
|
|
|
|
body: JSON.stringify(payload),
|
|
|
|
headers: headers,
|
|
|
|
}
|
|
|
|
fetch("http:\/\/localhost:8080/handle", body)
|
|
|
|
.then((response) => response.json())
|
|
|
|
.then((data) => {
|
|
|
|
sent.innerHTML = JSON.stringify(payload, undefined, 4);
|
|
|
|
received.innerHTML = JSON.stringify(data, undefined, 4);
|
|
|
|
if (data.error) {
|
|
|
|
console.log(data.message);
|
|
|
|
output.innerHTML += `<br><strong>Error:</strong>: ${data.message}`;
|
|
|
|
} else {
|
|
|
|
output.innerHTML += `<br><strong>Response from broker service</strong>: ${data.message}`;
|
|
|
|
}
|
|
|
|
})
|
|
|
|
.catch((error) => {
|
|
|
|
output.innerHTML += "<br><br>Error: " + error;
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2024-08-27 19:24:24 +00:00
|
|
|
</script>
|
|
|
|
{{end}}
|