Add a health check feature
k33g opened this issue · 3 comments
k33g commented
- for capsule http
- and if a function
health
exists in the wasm module => probably something to add to the MDK
Related issues:
k33g commented
func main() {
capsule.SetHandleHTTP(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) {
})
capsule.SetHandleHealthCheck(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) {
})
}
k33g commented
k33g commented
func main() { capsule.SetHandleHTTP(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) { }) capsule.SetHandleHealthCheck(func (param capsule.HTTPRequest) (capsule.HTTPResponse, error) { }) }
other solution: call exported function
//export OnHealthCheck
func OnHealthCheck() uint64 {
capsule.Print("⛑️ OnHealthCheck")
response := capsule.HTTPResponse{
JSONBody: `{"message": "OK"}`,
Headers: `{"Content-Type": "application/json; charset=utf-8"}`,
StatusCode: 200,
}
return capsule.Success([]byte(capsule.StringifyHTTPResponse(response)))
}