-
Notifications
You must be signed in to change notification settings - Fork 212
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' of https://github.com/aol/micro-server into ena…
…ble_s3_default_chain
- Loading branch information
Showing
23 changed files
with
666 additions
and
101 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,4 @@ | ||
version=0.91.5 | ||
version=0.91.8 | ||
springVersion=4.3.3.RELEASE | ||
springBootVersion=1.4.1.RELEASE | ||
jerseyVersion=2.24 | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
63 changes: 63 additions & 0 deletions
63
...ation-register/src/main/java/com/aol/micro/server/application/registry/UriInfoParser.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,63 @@ | ||
package com.aol.micro.server.application.registry; | ||
|
||
import cyclops.stream.ReactiveSeq; | ||
|
||
import javax.ws.rs.core.MultivaluedMap; | ||
import javax.ws.rs.core.UriInfo; | ||
import java.util.Arrays; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Optional; | ||
|
||
public class UriInfoParser { | ||
|
||
public static Optional<RegisterEntry> toRegisterEntry(UriInfo uriInfo) { | ||
if (uriInfo.getQueryParameters().isEmpty()) { | ||
return Optional.empty(); | ||
} else { | ||
MultivaluedMap<String, String> parameters = uriInfo.getQueryParameters(); | ||
RegisterEntry re = RegisterEntry.builder() | ||
.context(parameters.getFirst("context")) | ||
.hostname(parameters.getFirst("hostname")) | ||
.port(toInt(parameters.getFirst("port"))) | ||
.target(parameters.getFirst("target")) | ||
.externalPort(toInt(parameters.getFirst("externalPort"))) | ||
.module(parameters.getFirst("module")) | ||
.health(toHealth(parameters.getFirst("health"))) | ||
.build(); | ||
|
||
Map<String, String> manifest = ReactiveSeq.fromIterable(parameters.entrySet()) | ||
.filter(e -> e.getKey().startsWith("manifest.")) | ||
.toMap(e -> e.getKey().replace("manifest.", ""), e -> parameters.getFirst(e.getKey())); | ||
|
||
re.getManifest().clear(); | ||
re.getManifest().putAll(manifest); | ||
|
||
return Optional.of(re); | ||
} | ||
} | ||
|
||
private static Health toHealth(String health) { | ||
if (Objects.nonNull(health)) { | ||
try { | ||
return Health.valueOf(health); | ||
} catch (Exception e) { | ||
throw new IllegalArgumentException("'" + health + "' is not valid, valid values are " + | ||
Arrays.asList(Health.values())); | ||
} | ||
} | ||
return null; | ||
} | ||
|
||
private static int toInt(String port) { | ||
if (Objects.isNull(port)) | ||
return -1; | ||
|
||
try { | ||
return Integer.valueOf(port); | ||
} catch (Exception e) { | ||
throw new IllegalArgumentException("'" + port + "' is not a valid number."); | ||
} | ||
} | ||
|
||
} |
Oops, something went wrong.