Skip to content

Commit

Permalink
fix subject check
Browse files Browse the repository at this point in the history
  • Loading branch information
Fungx committed Dec 16, 2023
1 parent b85a58c commit ed8787f
Showing 1 changed file with 8 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -83,15 +83,21 @@ private void doInit() {
.handler(LoggerHandler.create())
.handler(ctx -> {
VertxMessageFactory.createReader(ctx.request())
.map(MessageReader::toEvent)
.map(r -> {
CloudEvent event = r.toEvent();
if (event.getSubject() == null) {
throw new IllegalStateException("attribute 'subject' cannot be null");
}
return event;
})
.onSuccess(event -> {
queue.add(event);
log.info("[HttpSourceConnector] Succeed to convert payload into CloudEvent. StatusCode={}", HttpResponseStatus.OK.code());
ctx.response().setStatusCode(HttpResponseStatus.OK.code()).end();
})
.onFailure(t -> {
log.error("[HttpSourceConnector] Malformed request. StatusCode={}", HttpResponseStatus.BAD_REQUEST.code(), t);
ctx.response().setStatusCode(HttpResponseStatus.BAD_REQUEST.code()).setStatusMessage(t.getMessage()).end();
ctx.response().setStatusCode(HttpResponseStatus.BAD_REQUEST.code()).end();
});
});
this.server = vertx.createHttpServer(new HttpServerOptions()
Expand Down

0 comments on commit ed8787f

Please sign in to comment.