mirror of https://github.com/status-im/go-waku.git
Fix /health REST API panic (#763)
* fix: panic in REST health endpoint to running node without RLN * chore: change title of each API file
This commit is contained in:
parent
d317b294a0
commit
3254d28968
|
@ -1,6 +1,6 @@
|
|||
openapi: 3.0.3
|
||||
info:
|
||||
title: Waku V2 node REST API
|
||||
title: Waku V2 node Debug REST API
|
||||
version: 1.0.0
|
||||
contact:
|
||||
name: VAC Team
|
||||
|
|
|
@ -30,19 +30,23 @@ func NewHealthService(node *node.WakuNode, m *chi.Mux) *HealthService {
|
|||
type HealthResponse string
|
||||
|
||||
func (d *HealthService) getHealth(w http.ResponseWriter, r *http.Request) {
|
||||
isReady, err := d.node.RLNRelay().IsReady(r.Context())
|
||||
if err != nil {
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
writeResponse(w, HealthResponse("Health check timed out"), http.StatusInternalServerError)
|
||||
} else {
|
||||
writeResponse(w, HealthResponse(err.Error()), http.StatusInternalServerError)
|
||||
if d.node.RLNRelay() != nil {
|
||||
isReady, err := d.node.RLNRelay().IsReady(r.Context())
|
||||
if err != nil {
|
||||
if errors.Is(err, context.DeadlineExceeded) {
|
||||
writeResponse(w, HealthResponse("Health check timed out"), http.StatusInternalServerError)
|
||||
} else {
|
||||
writeResponse(w, HealthResponse(err.Error()), http.StatusInternalServerError)
|
||||
}
|
||||
return
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
if isReady {
|
||||
writeResponse(w, HealthResponse("Node is healthy"), http.StatusOK)
|
||||
if isReady {
|
||||
writeResponse(w, HealthResponse("Node is healthy"), http.StatusOK)
|
||||
} else {
|
||||
writeResponse(w, HealthResponse("Node is not ready"), http.StatusInternalServerError)
|
||||
}
|
||||
} else {
|
||||
writeResponse(w, HealthResponse("Node is not ready"), http.StatusInternalServerError)
|
||||
writeResponse(w, HealthResponse("Non RLN healthcheck is not implemented"), http.StatusNotImplemented)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
openapi: 3.0.3
|
||||
info:
|
||||
title: Waku V2 node REST API
|
||||
title: Waku V2 node Health REST API
|
||||
version: 1.0.0
|
||||
contact:
|
||||
name: VAC Team
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
openapi: 3.0.3
|
||||
info:
|
||||
title: Waku V2 node REST API
|
||||
title: Waku V2 node Relay REST API
|
||||
version: 1.0.0
|
||||
contact:
|
||||
name: VAC Team
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
openapi: 3.0.3
|
||||
info:
|
||||
title: Waku V2 node REST API
|
||||
title: Waku V2 node Store REST API
|
||||
version: 1.0.0
|
||||
contact:
|
||||
name: VAC Team
|
||||
|
|
Loading…
Reference in New Issue