Skip to content

Commit

Permalink
wakunode2 and builder: only start rest server when enabled from conf
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivansete-status committed Apr 24, 2024
1 parent d448dd6 commit 60df791
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
11 changes: 5 additions & 6 deletions apps/wakunode2/wakunode2.nim
Original file line number Diff line number Diff line change
Expand Up @@ -146,12 +146,11 @@ when isMainModule:
error "Starting app failed", error = error
quit(QuitFailure)

if conf.rest:
rest_server_builder.startRestServerProtocolSupport(
restServer, wakunode2.node, wakunode2.wakuDiscv5, conf
).isOkOr:
error "Starting protocols support REST server failed.", error = $error
quit(QuitFailure)
rest_server_builder.startRestServerProtocolSupport(
restServer, wakunode2.node, wakunode2.wakuDiscv5, conf
).isOkOr:
error "Starting protocols support REST server failed.", error = $error
quit(QuitFailure)

wakunode2.startMetricsServerAndLogging().isOkOr:
error "Starting monitoring and external interfaces failed", error = error
Expand Down
6 changes: 6 additions & 0 deletions waku/waku_api/rest/builder.nim
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,9 @@ restServerNotInstalledTab = newTable[string, string]()
proc startRestServerEsentials*(
nodeHealthMonitor: WakuNodeHealthMonitor, conf: WakuNodeConf
): Result[WakuRestServerRef, string] =
if not conf.rest:
return

let requestErrorHandler: RestRequestErrorHandler = proc(
error: RestRequestError, request: HttpRequestRef
): Future[HttpResponseRef] {.async: (raises: [CancelledError]).} =
Expand Down Expand Up @@ -112,6 +115,9 @@ proc startRestServerProtocolSupport*(
wakuDiscv5: Option[WakuDiscoveryV5],
conf: WakuNodeConf,
): Result[void, string] =
if not conf.rest:
return

var router = restServer.router
## Admin REST API
if conf.restAdmin:
Expand Down

0 comments on commit 60df791

Please sign in to comment.