// Jedná se o komponentu napojenou na URL /user
@Path("/user/{username}")
public class UsersResource {
@GET // Metoda GET
@Produces("text/plain") // Generuje Content-Type text/plain
public String getUserAsText(@PathParameter("username") String user) {
return user; // vrátíme tento text
}
@GET // Metoda GET
@Produces("text/xml") // Generuje Content-Type text/xml
@Path("/xml") // XML je přístupné pod názvem /user/{username}/xml
public String getUserAsXml(@PathParameter("username") String user) {
return "<xml>" + user + "</xml>"; // vrátíme tento text
}
}