HelloWorld.java 718 Bytes
Newer Older
Luca Arrotta's avatar
Luca Arrotta committed
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18
package REST.services;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;

@Path("/helloworld")
public class HelloWorld {

    @GET
    @Produces("text/plain")
    public String helloWorld(){
        return "Hello world!";
    }

    @GET
    @Path("{name}")
19
    @Produces({"text/plain"})
Luca Arrotta's avatar
Luca Arrotta committed
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41
    public String helloWorldName(@PathParam("name") String name){

        return "Hello, "+name+"!";

    }

    @GET
    @Produces("application/json")
    public String helloWorld2(){
        return "{\"message\": \"helloWorld\"}";

    }

    @Path("inner")
    @GET
    @Produces("text/plain")
    public String innerHello(){

        return "Inner Hello!";
    }

}