If you want to build a REST API server with Scala I put together a project for you to start with. It uses Scala, Scalate, Maven, Jersey, JAX-RS, please feel free to fork it on Github.
Here's what you have to do:
1) Go to https://github.com/feliperazeek/scala-rest
2) Fork the project
3) git clone YOUR_NEW_PROJECT (for example: git clone git@github.com:feliperazeek/scala-rest.git)
4) mvn jetty:run
5) Then in your browser http://localhost:8080/vendor/hello.json or http://localhost:8080/vendor/hello.xml
Scala Code:
import javax.ws.rs._ import javax.ws.rs.ext._ @Provider @Path("/vendor") class VendorService { @GET @Path("/hello.json") @Produces(Array("application/json")) def getMediaType = "hello" @GET @Path("/hello.xml") @Produces(Array("text/json")) def getHTML = "hello" }Enjoy!
No comments:
Post a Comment