Added reference to Jersey for RESTful services.

Added Api package.
Added BlocksResource as first candidate for API implementation.
This commit is contained in:
Kc
2018-07-18 23:42:40 +02:00
parent ad250e57c8
commit 2fc74ac583
2 changed files with 33 additions and 0 deletions

View File

@@ -0,0 +1,28 @@
package api;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.MediaType;
import repository.DataException;
import repository.Repository;
import repository.RepositoryManager;
@Path("blocks")
@Produces(MediaType.APPLICATION_JSON)
public class BlocksResource {
@GET
@Path("/height")
public static String getHeight()
{
try (final Repository repository = RepositoryManager.getRepository()) {
return String.valueOf(repository.getBlockRepository().getBlockchainHeight());
} catch (Exception e) {
throw new WebApplicationException("What happened?");
}
}
}