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
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
title: Waku V2 node REST API
|
title: Waku V2 node Debug REST API
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
contact:
|
contact:
|
||||||
name: VAC Team
|
name: VAC Team
|
||||||
|
|
|
@ -30,19 +30,23 @@ func NewHealthService(node *node.WakuNode, m *chi.Mux) *HealthService {
|
||||||
type HealthResponse string
|
type HealthResponse string
|
||||||
|
|
||||||
func (d *HealthService) getHealth(w http.ResponseWriter, r *http.Request) {
|
func (d *HealthService) getHealth(w http.ResponseWriter, r *http.Request) {
|
||||||
isReady, err := d.node.RLNRelay().IsReady(r.Context())
|
if d.node.RLNRelay() != nil {
|
||||||
if err != nil {
|
isReady, err := d.node.RLNRelay().IsReady(r.Context())
|
||||||
if errors.Is(err, context.DeadlineExceeded) {
|
if err != nil {
|
||||||
writeResponse(w, HealthResponse("Health check timed out"), http.StatusInternalServerError)
|
if errors.Is(err, context.DeadlineExceeded) {
|
||||||
} else {
|
writeResponse(w, HealthResponse("Health check timed out"), http.StatusInternalServerError)
|
||||||
writeResponse(w, HealthResponse(err.Error()), http.StatusInternalServerError)
|
} else {
|
||||||
|
writeResponse(w, HealthResponse(err.Error()), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
if isReady {
|
if isReady {
|
||||||
writeResponse(w, HealthResponse("Node is healthy"), http.StatusOK)
|
writeResponse(w, HealthResponse("Node is healthy"), http.StatusOK)
|
||||||
|
} else {
|
||||||
|
writeResponse(w, HealthResponse("Node is not ready"), http.StatusInternalServerError)
|
||||||
|
}
|
||||||
} else {
|
} 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
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
title: Waku V2 node REST API
|
title: Waku V2 node Health REST API
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
contact:
|
contact:
|
||||||
name: VAC Team
|
name: VAC Team
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
title: Waku V2 node REST API
|
title: Waku V2 node Relay REST API
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
contact:
|
contact:
|
||||||
name: VAC Team
|
name: VAC Team
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
openapi: 3.0.3
|
openapi: 3.0.3
|
||||||
info:
|
info:
|
||||||
title: Waku V2 node REST API
|
title: Waku V2 node Store REST API
|
||||||
version: 1.0.0
|
version: 1.0.0
|
||||||
contact:
|
contact:
|
||||||
name: VAC Team
|
name: VAC Team
|
||||||
|
|
Loading…
Reference in New Issue