ECOM/HelloREST.java

From air
Jump to navigation Jump to search
package ecom.web;
 
import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.PUT;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.Context;
import javax.ws.rs.core.UriInfo;
 
/**
 * Root resource (exposed at "hellores" path)
 */
@Path("hellores")
public class HelloREST {
    @Context
    private UriInfo context;
 
    /** Creates a new instance of HelloREST */
    public HelloREST() {
    }
 
    /**
     * Retrieves representation of an instance of HelloREST
     * @return an instance of java.lang.String
     */
    @GET
    @Produces("text/html")
    public String getHtml() {
        return "<html lang=\"en\"><body><h1>Hello, World!!</h1></body></html>";
    }

    /**
     * Retrieves representation of an instance of HelloREST
     * @return an instance of java.lang.String
     */
    @GET
    @Produces("application/json")
    public String getJSON() {
        return "{msg: \"Hello World !\"}";
    }

}