Documentation ¶
Overview ¶
Package health provides a widget which displays the synchronization status of payment methods. So far it only supports BTCPay Server.
Register the health handler in your HTTP router:
router.Handler(http.MethodGet, "/payment-health", health.Server{btcpayStore})
Parse the health template string along with your HTML templates:
t = template.Must(t.Parse(health.TemplateString))
Execute the template:
{{template "health"}}
Index ¶
Constants ¶
View Source
const TemplateString = `
{{define "health"}}
<script>
function updateHealth() {
var xhr = new XMLHttpRequest();
xhr.onreadystatechange = function() {
if(xhr.readyState == 4) {
let content = "";
if(xhr.status == 200) {
let data = JSON.parse(xhr.responseText);
for(item of data) {
content = content + ` + backtick + `<span class="badge bg-${item.Synced ? 'success' : 'danger'} my-2">${item.Name}: ${item.Synced ? 'synced' : 'out of sync'}</span> ` + backtick + `;
}
} else {
content = '<span class="badge bg-warning">could not connect</span>';
}
document.getElementById("health-widget").innerHTML = content;
}
}
xhr.open("GET", "/payment-health", true); // true for asynchronous
xhr.send(null);
setTimeout(function(){
updateHealth();
}, 10*1000); // 10 seconds
}
document.write('<span id="health-widget"></span>');
updateHealth();
</script>
<noscript>
<span class="badge bg-secondary">requires JavaScript</span>
</noscript>
{{end}}`
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
Click to show internal directories.
Click to hide internal directories.