Skip to content

Instantly share code, notes, and snippets.



Block or report user

Report or block YEMEAC

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
YEMEAC / consulAddRemoveService.json
Created Oct 5, 2018
register and delete service in consul with curl
View consulAddRemoveService.json
curl -X PUT \ \
-H 'cache-control: no-cache' \
-H 'content-type: application/json' \
-H 'postman-token: 9aa3163f-31b9-8c8f-f9cd-6feaca81d4ce' \
-d '{
"Datacenter": "dc1",
"Node": "externalServices",
"Address": "",
"Service": {
Created Oct 2, 2018
Wanted to throw an exception using Reactive Spring only if username a new user wanted to have was being used for someone what was't him
private Mono<UserDto> validateUpdate(Long partyId, UserDto request) {
return partyClient.getIndividual(partyId)
.flatMap(r -> securityClient.getByUserName(request.getUsername()))
.switchIfEmpty(Mono.just(UserModel.builder().withId(partyId).build())) //dummy to have something to compare with and kee the reactive flow "flowing"
.flatMap(r -> {
if (!r.getId().equals(partyId)) {
throw new UserAlreadyExistsException("Username already taken");
return Mono.just(request);
Last active Oct 16, 2018
Wanted to throw an exception using Reactive Spring only if a service call had results, also a good trick to add your on function directly in a map
private Mono<UserDto> validateUserNameAvailable(UserDto user) {
Mono<Boolean> result = securityClient.getByUserName(user.getUserName()).hasElement();
return result.flatMap(value -> {
if (value) {
throw new UserAlreadyExistsException(
String.format("User {} already exists", user.getUserName()));
return Mono.just(user);
You can’t perform that action at this time.