mirror of
https://github.com/Qortal/qortal.git
synced 2025-03-18 21:24:58 +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:
parent
ad250e57c8
commit
2fc74ac583
5
pom.xml
5
pom.xml
@ -42,5 +42,10 @@
|
|||||||
<artifactId>commons-net</artifactId>
|
<artifactId>commons-net</artifactId>
|
||||||
<version>3.3</version>
|
<version>3.3</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
|
<dependency>
|
||||||
|
<groupId>org.glassfish.jersey.core</groupId>
|
||||||
|
<artifactId>jersey-server</artifactId>
|
||||||
|
<version>2.27</version>
|
||||||
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
</project>
|
</project>
|
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?");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user