From 02950f2c09713573b042f6c5440896eb4e8d9598 Mon Sep 17 00:00:00 2001 From: Bert Spaan Date: Thu, 13 Aug 2015 09:52:51 +0200 Subject: [PATCH] =?UTF-8?q?ping!=20=F0=9F=8E=BE=20pong!=20=F0=9F=8E=BE=20c?= =?UTF-8?q?loses=20#5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ping.sh | 3 +++ .../histograph/plugins/ExpandConcepts.java | 19 ++++++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) create mode 100755 ping.sh diff --git a/ping.sh b/ping.sh new file mode 100755 index 0000000..e53e84b --- /dev/null +++ b/ping.sh @@ -0,0 +1,3 @@ +#!/usr/bin/env bash + +curl http://localhost:7474/histograph/ping diff --git a/src/main/java/org/waag/histograph/plugins/ExpandConcepts.java b/src/main/java/org/waag/histograph/plugins/ExpandConcepts.java index a034b7c..045a856 100644 --- a/src/main/java/org/waag/histograph/plugins/ExpandConcepts.java +++ b/src/main/java/org/waag/histograph/plugins/ExpandConcepts.java @@ -18,11 +18,12 @@ import javax.ws.rs.core.Response; import javax.ws.rs.core.StreamingOutput; import java.io.*; +import java.nio.charset.Charset; import java.util.ArrayList; import javax.ws.rs.core.Context; -@javax.ws.rs.Path( "/expand" ) +@javax.ws.rs.Path( "/" ) public class ExpandConcepts { private GraphDatabaseService graphDb; @@ -50,9 +51,21 @@ public ExpandConcepts(@Context GraphDatabaseService graphDb) { this.objectMapper = new ObjectMapper(); } + @GET + @javax.ws.rs.Path("/ping") + public Response ping(@Context HttpServletRequest request, final InputStream requestBody) { + StreamingOutput stream = new StreamingOutput() { + @Override + public void write(OutputStream os) throws IOException, WebApplicationException { + os.write("pong".getBytes(Charset.forName("UTF-8"))); + } + }; + return Response.ok().entity(stream).type(MediaType.TEXT_PLAIN).build(); + } + @POST - @javax.ws.rs.Path("/") - public Response chips(@Context HttpServletRequest request, final InputStream requestBody) { + @javax.ws.rs.Path("/expand") + public Response expand(@Context HttpServletRequest request, final InputStream requestBody) { StreamingOutput stream = new StreamingOutput() { @Override