HelloWorld.java 712 Bytes
Newer Older
Gabriele Civitarese's avatar
Gabriele Civitarese committed
1 2 3 4
package services;

import javax.ws.rs.GET;
import javax.ws.rs.Path;
Gabriele Civitarese's avatar
Gabriele Civitarese committed
5
import javax.ws.rs.PathParam;
Gabriele Civitarese's avatar
Gabriele Civitarese committed
6 7 8 9 10 11 12 13 14 15 16 17 18
import javax.ws.rs.Produces;

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

    @GET
    @Produces("text/plain")
    public String helloWorld(){

        return "Hello world!";

    }

Gabriele Civitarese's avatar
Gabriele Civitarese committed
19 20 21 22 23 24 25 26 27
    @GET
    @Path("{name}")
    @Produces("text/plain")
    public String helloWorldName(@PathParam("name") String name){

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

    }

Gabriele Civitarese's avatar
Gabriele Civitarese committed
28 29 30 31 32 33 34 35 36 37 38 39 40 41
    @GET
    @Produces("application/json")
    public String helloWorld2(){
        return "{\"message\": \"helloWorld\"}";
    }

    @Path("/inner")
    @GET
    @Produces("text/plain")
    public String innerHello(){
        return "Inner Hello!";
    }

}