Difference between revisions of "ECOM/HelloREST.java"

From air
Jump to navigation Jump to search
(Created page with "<pre> package fr.polytechgrenoble.ricm.ecom; import javax.ws.rs.Consumes; import javax.ws.rs.GET; import javax.ws.rs.PUT; import javax.ws.rs.Path; import javax.ws.rs.Produce...")
 
 
Line 1: Line 1:
  +
<syntaxhighlight lang="java">
<pre>
 
package fr.polytechgrenoble.ricm.ecom;
+
package ecom.web;
 
 
 
import javax.ws.rs.Consumes;
 
import javax.ws.rs.Consumes;
Line 43: Line 43:
   
 
}
 
}
  +
</syntaxhighlight>
</pre>
 

Latest revision as of 11:05, 1 October 2014

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 !\"}";
    }

}