Skip to content

Commit

Permalink
fixes #172 put serviceId into the health endpoint as path parameter
Browse files Browse the repository at this point in the history
  • Loading branch information
stevehu committed Aug 18, 2018
1 parent 5751b7e commit 2a3f6f4
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,11 @@
import com.networknt.oas.model.*;

import java.io.ByteArrayInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.net.MalformedURLException;
import java.net.URL;
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.nio.file.StandardCopyOption;
Expand Down Expand Up @@ -89,6 +87,7 @@ public void generate(String targetPath, Object model, Any config) throws IOExcep
String dockerOrganization = config.toString("dockerOrganization");
prometheusMetrics = config.toBoolean("prometheusMetrics");
String version = config.toString("version");
String serviceId = config.get("groupId") + "." + config.get("artifactId") + "-" + config.get("version");

if(dockerOrganization == null || dockerOrganization.length() == 0) dockerOrganization = "networknt";

Expand All @@ -104,7 +103,7 @@ public void generate(String targetPath, Object model, Any config) throws IOExcep

transfer(targetPath, "docker", "Dockerfile", templates.rest.dockerfile.template(config, expose));
transfer(targetPath, "docker", "Dockerfile-Redhat", templates.rest.dockerfileredhat.template(config, expose));
transfer(targetPath, "", "build.sh", templates.rest.buildSh.template(dockerOrganization, config.get("groupId") + "." + config.get("artifactId") + "-" + config.get("version")));
transfer(targetPath, "", "build.sh", templates.rest.buildSh.template(dockerOrganization, serviceId));
transfer(targetPath, "", ".gitignore", templates.rest.gitignore.template());
transfer(targetPath, "", "README.md", templates.rest.README.template());
transfer(targetPath, "", "LICENSE", templates.rest.LICENSE.template());
Expand All @@ -114,8 +113,8 @@ public void generate(String targetPath, Object model, Any config) throws IOExcep
// config
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "service.yml", templates.rest.openapi.service.template(config));

transfer(targetPath, ("src.main.resources.config").replace(".", separator), "server.yml", templates.rest.server.template(config.get("groupId") + "." + config.get("artifactId") + "-" + config.get("version"), enableHttp, httpPort, enableHttps, httpsPort, enableRegistry, version));
transfer(targetPath, ("src.test.resources.config").replace(".", separator), "server.yml", templates.rest.server.template(config.get("groupId") + "." + config.get("artifactId") + "-" + config.get("version"), enableHttp, "49587", enableHttps, "49588", enableRegistry, version));
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "server.yml", templates.rest.server.template(serviceId, enableHttp, httpPort, enableHttps, httpsPort, enableRegistry, version));
transfer(targetPath, ("src.test.resources.config").replace(".", separator), "server.yml", templates.rest.server.template(serviceId, enableHttp, "49587", enableHttps, "49588", enableRegistry, version));

transfer(targetPath, ("src.main.resources.config").replace(".", separator), "secret.yml", templates.rest.secret.template());
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "openapi-security.yml", templates.rest.openapiSecurity.template());
Expand All @@ -135,7 +134,7 @@ public void generate(String targetPath, Object model, Any config) throws IOExcep

List<Map<String, Object>> operationList = getOperationList(model);
// routing
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "handler.yml", templates.rest.openapi.handlerYml.template(handlerPackage, operationList, prometheusMetrics));
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "handler.yml", templates.rest.openapi.handlerYml.template(serviceId, handlerPackage, operationList, prometheusMetrics));

// model
if(overwriteModel) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,7 @@ public void generate(String targetPath, Object model, Any config) throws IOExcep
String dockerOrganization = config.toString("dockerOrganization");
prometheusMetrics = config.toBoolean("prometheusMetrics");
String version = config.toString("version");
String serviceId = config.get("groupId") + "." + config.get("artifactId") + "-" + config.get("version");

if(dockerOrganization == null || dockerOrganization.length() == 0) dockerOrganization = "networknt";

Expand All @@ -100,7 +101,7 @@ public void generate(String targetPath, Object model, Any config) throws IOExcep

transfer(targetPath, "docker", "Dockerfile", templates.rest.dockerfile.template(config, expose));
transfer(targetPath, "docker", "Dockerfile-Redhat", templates.rest.dockerfileredhat.template(config, expose));
transfer(targetPath, "", "build.sh", templates.rest.buildSh.template(dockerOrganization, config.get("groupId") + "." + config.get("artifactId") + "-" + config.get("version")));
transfer(targetPath, "", "build.sh", templates.rest.buildSh.template(dockerOrganization, serviceId));
transfer(targetPath, "", ".gitignore", templates.rest.gitignore.template());
transfer(targetPath, "", "README.md", templates.rest.README.template());
transfer(targetPath, "", "LICENSE", templates.rest.LICENSE.template());
Expand All @@ -110,8 +111,8 @@ public void generate(String targetPath, Object model, Any config) throws IOExcep
// config
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "service.yml", templates.rest.swagger.service.template(config));

transfer(targetPath, ("src.main.resources.config").replace(".", separator), "server.yml", templates.rest.server.template(config.get("groupId") + "." + config.get("artifactId") + "-" + config.get("version"), enableHttp, httpPort, enableHttps, httpsPort, enableRegistry, version));
transfer(targetPath, ("src.test.resources.config").replace(".", separator), "server.yml", templates.rest.server.template(config.get("groupId") + "." + config.get("artifactId") + "-" + config.get("version"), enableHttp, "49587", enableHttps, "49588", enableRegistry, version));
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "server.yml", templates.rest.server.template(serviceId, enableHttp, httpPort, enableHttps, httpsPort, enableRegistry, version));
transfer(targetPath, ("src.test.resources.config").replace(".", separator), "server.yml", templates.rest.server.template(serviceId, enableHttp, "49587", enableHttps, "49588", enableRegistry, version));

transfer(targetPath, ("src.main.resources.config").replace(".", separator), "secret.yml", templates.rest.secret.template());
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "swagger-security.yml", templates.rest.swaggerSecurity.template());
Expand All @@ -131,7 +132,7 @@ public void generate(String targetPath, Object model, Any config) throws IOExcep

List<Map<String, Any>> operationList = getOperationList(model);
// routing
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "handler.yml", templates.rest.swagger.handlerYml.template(handlerPackage, operationList, prometheusMetrics));
transfer(targetPath, ("src.main.resources.config").replace(".", separator), "handler.yml", templates.rest.swagger.handlerYml.template(serviceId, handlerPackage, operationList, prometheusMetrics));


// model
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import java.util.Map
@import java.util.List
@import com.jsoniter.any.Any
@args (String handlerPackage, List<Map<String, Object>> items, boolean prometheusMetrics)
@args (String serviceId, String handlerPackage, List<Map<String, Object>> items, boolean prometheusMetrics)

# Handler middleware chain configuration
---
Expand Down Expand Up @@ -75,7 +75,7 @@ paths:
- default
- @with (p = handlerPackage + ".") {@p}@item.get("handlerName")
}
- path: '/health'
- path: '/health/@serviceId'
method: 'get'
exec:
- health
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
@import java.util.Map
@import java.util.List
@import com.jsoniter.any.Any
@args (String handlerPackage, List<Map<String, Any>> items, boolean prometheusMetrics)
@args (String serviceId, String handlerPackage, List<Map<String, Any>> items, boolean prometheusMetrics)

# Handler middleware chain configuration
---
Expand Down Expand Up @@ -75,7 +75,7 @@ paths:
- default
- @with (p = handlerPackage + ".") {@p}@item.get("handlerName")
}
- path: '/health'
- path: '/health/@serviceId'
method: 'get'
exec:
- health
Expand Down

0 comments on commit 2a3f6f4

Please sign in to comment.