Skip to content

Commit

Permalink
allow non-standard http status codes in the http api
Browse files Browse the repository at this point in the history
Signed-off-by: Johannes Schneider <johannes.schneider@bosch.io>
  • Loading branch information
jokraehe committed May 3, 2022
1 parent 2967d5e commit a565786
Showing 1 changed file with 3 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -211,7 +211,9 @@ public AbstractActor.Receive createReceive() {
}

private static HttpResponse createHttpResponse(final HttpStatus httpStatus) {
return HttpResponse.create().withStatus(httpStatus.getCode());
final var statusCode = StatusCodes.lookup(httpStatus.getCode())
.orElse(StatusCodes.custom(httpStatus.getCode(), "custom", "custom"));
return HttpResponse.create().withStatus(statusCode);
}

private void handleCommand(final Command<?> command) {
Expand Down Expand Up @@ -427,8 +429,6 @@ private HttpResponse handleMessageResponseMessage(final MessageCommandResponse<?
final Optional<?> optionalPayload = message.getPayload();
final Optional<ByteBuffer> optionalRawPayload = message.getRawPayload();
final var responseStatus = Optional.of(messageCommandResponse.getHttpStatus())
.filter(httpStatus -> StatusCodes.lookup(httpStatus.getCode()).isPresent())
// only allow HTTP status which are known to akka-http
.filter(httpStatus -> !HttpStatus.BAD_GATEWAY.equals(httpStatus));
// filter "bad gateway" 502 from being used as this is used Ditto internally for graceful HTTP shutdown

Expand Down

0 comments on commit a565786

Please sign in to comment.