Skip to content

Instantly share code, notes, and snippets.

@vvavepacket
Created August 10, 2016 11:59
Show Gist options
  • Select an option

  • Save vvavepacket/0fc1d1a4151fe7c0909be96bc31cee83 to your computer and use it in GitHub Desktop.

Select an option

Save vvavepacket/0fc1d1a4151fe7c0909be96bc31cee83 to your computer and use it in GitHub Desktop.
HelloWorldResource.java
package org.neo4j.examples.server.unmanaged;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.MediaType;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import org.neo4j.graphdb.GraphDatabaseService;
import org.neo4j.string.UTF8;
@Path( "/helloworld" )
public class HelloWorldResource {
private final GraphDatabaseService database;
public HelloWorldResource( @Context GraphDatabaseService database )
{
this.database = database;
}
@GET
@Produces( MediaType.TEXT_PLAIN )
@Path( "/{nodeId}" )
public Response hello( @PathParam( "nodeId" ) long nodeId )
{
// Do stuff with the database
return Response.status( Status.OK ).entity( UTF8.encode( "Hello World, nodeId=" + nodeId ) ).build();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment