HelloWorld.java 714 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
    @GET
    @Produces("application/json")
    public String helloWorld2(){
Gabriele Civitarese's avatar
Gabriele Civitarese committed
31

Gabriele Civitarese's avatar
Gabriele Civitarese committed
32
        return "{\"message\": \"helloWorld\"}";
Gabriele Civitarese's avatar
Gabriele Civitarese committed
33

Gabriele Civitarese's avatar
Gabriele Civitarese committed
34 35
    }

Gabriele Civitarese's avatar
Gabriele Civitarese committed
36
    @Path("inner")
Gabriele Civitarese's avatar
Gabriele Civitarese committed
37 38 39
    @GET
    @Produces("text/plain")
    public String innerHello(){
Gabriele Civitarese's avatar
Gabriele Civitarese committed
40

Gabriele Civitarese's avatar
Gabriele Civitarese committed
41 42 43 44
        return "Inner Hello!";
    }

}