Incomplete RESTful API for IRC
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

VersionResource.java 968B

12345678910111213141516171819202122232425262728293031323334353637
  1. package name.smith.chris.restirc.resources;
  2. import com.dmdirc.util.io.TextFile;
  3. import java.io.IOException;
  4. import javax.ws.rs.GET;
  5. import javax.ws.rs.Path;
  6. import javax.ws.rs.Produces;
  7. import javax.ws.rs.WebApplicationException;
  8. import javax.ws.rs.core.Response;
  9. /**
  10. * Version resource. Simply returns the current version of the application.
  11. */
  12. @Path("/version")
  13. public class VersionResource {
  14. /**
  15. * Gets the textual representation of the version.
  16. *
  17. * @return The textual representation of the version.
  18. */
  19. @GET
  20. @Produces("text/plain")
  21. public String getVersion() {
  22. try {
  23. final TextFile textFile = new TextFile(getClass()
  24. .getResourceAsStream("/name/smithc/chris/version"));
  25. return textFile.getLines().get(0);
  26. } catch (IOException ex) {
  27. throw new WebApplicationException(ex,
  28. Response.Status.INTERNAL_SERVER_ERROR);
  29. }
  30. }
  31. }