diff options
author | Martin Polden <mpolden@mpolden.no> | 2018-01-12 13:19:11 +0100 |
---|---|---|
committer | Martin Polden <mpolden@mpolden.no> | 2018-01-12 13:19:11 +0100 |
commit | df10ff21943086fdc8f22c0b2c25fe8ed5ca1599 (patch) | |
tree | 5157a295b98a59209f518bcd108e9a3311152969 /controller-server | |
parent | 969ce8d9b62d26529e121600b141cdde41c22696 (diff) |
Remove outdated controller root handler
Diffstat (limited to 'controller-server')
3 files changed, 0 insertions, 152 deletions
diff --git a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/RootHandler.java b/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/RootHandler.java deleted file mode 100644 index 89baa1cfa39..00000000000 --- a/controller-server/src/main/java/com/yahoo/vespa/hosted/controller/restapi/RootHandler.java +++ /dev/null @@ -1,93 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.restapi; - -import com.fasterxml.jackson.databind.JsonNode; -import com.fasterxml.jackson.databind.ObjectMapper; -import com.fasterxml.jackson.databind.node.ArrayNode; -import com.fasterxml.jackson.databind.node.JsonNodeFactory; -import com.fasterxml.jackson.databind.node.ObjectNode; -import com.yahoo.container.jdisc.HttpRequest; -import com.yahoo.container.jdisc.HttpResponse; -import com.yahoo.container.jdisc.LoggingRequestHandler; - -import java.io.IOException; -import java.io.OutputStream; -import java.net.URI; - -/** - * Responds to requests for the root path of the controller by listing the available web service API's. - * - * FAQ: - * - Q: Why do we need this when the container provides a perfectly fine root response listing all handlers by default? - * - A: Because we also have Jersey API's and those are not included in the default response. - * - * @author Oyvind Gronnesby - * @author bratseth - */ -public class RootHandler extends LoggingRequestHandler { - - public RootHandler(LoggingRequestHandler.Context parentCtx) { - super(parentCtx); - } - - @Override - public HttpResponse handle(HttpRequest httpRequest) { - final URI requestUri = httpRequest.getUri(); - return new ControllerRootPathResponse(requestUri); - } - - private static class ControllerRootPathResponse extends HttpResponse { - - private final URI uri; - - public ControllerRootPathResponse(URI uri) { - super(200); - this.uri = uri; - } - - @Override - public void render(OutputStream outputStream) throws IOException { - ObjectMapper mapper = new ObjectMapper(); - mapper.writeValue(outputStream, buildResponseObject()); - } - - @Override - public String getContentType() { - return "application/json"; - } - - private JsonNode buildResponseObject() { - ObjectNode output = new ObjectNode(JsonNodeFactory.instance); - ArrayNode services = output.putArray("services"); - - jerseyService(services, "provision", "/provision/v1/", "/provision/application.wadl"); - jerseyService(services, "statuspage", "/statuspage/v1/", "/statuspage/application.wadl"); - jerseyService(services, "zone", "/zone/v1/", "/zone/application.wadl"); - jerseyService(services, "zone", "/zone/v2/", "/zone/application.wadl"); - handlerService(services, "application", "/application/v4/"); - handlerService(services, "deployment", "/deployment/v1/"); - handlerService(services, "screwdriver", "/screwdriver/v1/release/vespa"); - - return output; - } - - private void jerseyService(ArrayNode parent, String name, String url, String wadl) { - ObjectNode service = parent.addObject(); - service.put("name", name); - service.put("url", controllerUri(url)); - service.put("wadl", controllerUri(wadl)); - } - - private void handlerService(ArrayNode parent, String name, String url) { - ObjectNode service = parent.addObject(); - service.put("name", name); - service.put("url", controllerUri(url)); - } - - private String controllerUri(String path) { - return uri.resolve(path).toString(); - } - - } - -} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/RootHandlerTest.java b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/RootHandlerTest.java deleted file mode 100644 index 9534dd65d7f..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/RootHandlerTest.java +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright 2017 Yahoo Holdings. Licensed under the terms of the Apache 2.0 license. See LICENSE in the project root. -package com.yahoo.vespa.hosted.controller.restapi; - -import com.yahoo.application.container.handler.Request; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; - -/** - * @author bratseth - */ -public class RootHandlerTest extends ControllerContainerTest { - - @Test - public void testRootRequest() throws IOException { - ContainerTester tester = new ContainerTester(container, - "src/test/java/com/yahoo/vespa/hosted/controller/restapi/"); - tester.assertResponse(new Request("http://localhost:8080/"), - new File("root-response.json"), 200); - } - -} diff --git a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/root-response.json b/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/root-response.json deleted file mode 100644 index f4a524a5943..00000000000 --- a/controller-server/src/test/java/com/yahoo/vespa/hosted/controller/restapi/root-response.json +++ /dev/null @@ -1,36 +0,0 @@ -{ - "services":[ - { - "name":"provision", - "url":"http://localhost:8080/provision/v1/", - "wadl":"http://localhost:8080/provision/application.wadl" - }, - { - "name":"statuspage", - "url":"http://localhost:8080/statuspage/v1/", - "wadl":"http://localhost:8080/statuspage/application.wadl" - }, - { - "name":"zone", - "url":"http://localhost:8080/zone/v1/", - "wadl":"http://localhost:8080/zone/application.wadl" - }, - { - "name":"zone", - "url":"http://localhost:8080/zone/v2/", - "wadl":"http://localhost:8080/zone/application.wadl" - }, - { - "name":"application", - "url":"http://localhost:8080/application/v4/" - }, - { - "name":"deployment", - "url":"http://localhost:8080/deployment/v1/" - }, - { - "name":"screwdriver", - "url":"http://localhost:8080/screwdriver/v1/release/vespa" - } - ] -} |