Код: Выделить всё
public Mono downloadAttachment(final ServerRequest request) {
final var idPercorso = request.queryParam("idPercorso")
.map(Integer::parseInt).orElse(null);
}
Mono additionalCalcualtions(MapFile mapFile, ServerRequest request){
return Mono.zip(parseUserInfo(request), request.bodyToMono(ObjectNode.class))
.flatMap(t -> {
//var dto = t.getT2();
return silverMountainService(t.getT1()).downloadMappaPercorso(StorageType.parse(mapFile.storageType),mapFile.omniaClass, mapFile.getFileName()
)
.flatMap(fileResult -> ServerResponse.ok()
.headers(h -> h.setContentDisposition(
Optional.ofNullable(mapFile.getFileName())
.filter(StringUtils::isNotBlank)
.map(filename -> ContentDisposition.attachment().filename(mapFile.getFileName()).build())
.orElseGet(() -> ContentDisposition.inline().build() )
))
.contentType(MediaType.APPLICATION_OCTET_STREAM)
.body(BodyInserters.fromValue(fileResult.getContent()))
);
})
.onErrorResume(CustomHttpException.class, assEx -> {
log.error("Error({}): {}", assEx.getErrorId(), assEx.getMessage());
return ServerResponse.status(assEx.getHttpStatus()).bodyValue(String.format("ErrorID: %s", assEx.getErrorId()));
})
.onErrorResume(Exception.class, ex -> {
var errId = UUID.randomUUID().toString();
log.error(String.format("Error(%s) %s", errId, ex.getMessage()), ex);
return ServerResponse.status(HttpStatus.INTERNAL_SERVER_ERROR).bodyValue(String.format("ErrorID: %s", errId));
});
}
Код: Выделить всё
myUrl/downloadMappa?idPercorso=2
Код: Выделить всё
{}
Как мне изменить свой код, чтобы он принимал NULL в качестве тела?
Подробнее здесь: https://stackoverflow.com/questions/792 ... th-webflux
Мобильная версия