use of tech.pegasys.teku.infrastructure.http.HttpStatusCodes.SC_BAD_REQUEST in project teku by ConsenSys.
the class PostVoluntaryExit method handle.
@OpenApi(path = ROUTE, method = HttpMethod.POST, summary = "Submit signed voluntary exit", tags = { TAG_BEACON }, description = "Submits signed voluntary exit object to node's pool and if it passes validation node MUST broadcast it to network.", requestBody = @OpenApiRequestBody(content = { @OpenApiContent(from = SignedVoluntaryExit.class) }), responses = { @OpenApiResponse(status = RES_OK, description = "Signed voluntary exit has been successfully validated, added to the pool, and broadcast."), @OpenApiResponse(status = RES_BAD_REQUEST, description = "Invalid voluntary exit, it will never pass validation so it's rejected"), @OpenApiResponse(status = RES_INTERNAL_ERROR) })
@Override
public void handle(final Context ctx) throws Exception {
try {
final SignedVoluntaryExit exit = parseRequestBody(ctx.body(), SignedVoluntaryExit.class);
ctx.future(nodeDataProvider.postVoluntaryExit(exit).thenApplyChecked(result -> handleResponseContext(ctx, result)));
} catch (final IllegalArgumentException e) {
LOG.debug("Voluntary exit failed", e);
ctx.json(BadRequest.badRequest(jsonProvider, e.getMessage()));
ctx.status(SC_BAD_REQUEST);
}
}
Aggregations