mirror of
https://github.com/Qortal/qortal.git
synced 2025-07-23 04:36:50 +00:00
Added reference to Jersey for RESTful services.
Added Api package. Added BlocksResource as first candidate for API implementation.
This commit is contained in:
28
src/api/BlocksResource.java
Normal file
28
src/api/BlocksResource.java
Normal 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?");
|
||||
}
|
||||
}
|
||||
|
||||
}
|
Reference in New Issue
Block a user