package de.asw.courses.web2016.demo.backend.http;

import javax.ws.rs.Consumes;
import javax.ws.rs.GET;
import javax.ws.rs.POST;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

/**
 * <pre>{@code curl default Accept: *\/*}</pre>
 * <pre>
 * {@code curl -v http://localhost:8080/asw2016-demo-webapp/resources/content-negotiation }
 * </pre>
 *
 * Browser?
 * Try with chrome...
 * @see http://localhost:8080/asw2016-demo-webapp/resources/content-negotiation
 * 
 * @author tom
 */
@Path("/content-negotiation")
public class ContentNegotiationExampleResource {

	/**
	 * <pre>
	 * {@code curl -v -H "Accept: application/xml" http://localhost:8080/asw2016-demo-webapp/resources/content-negotiation }
	 * </pre>
	 * 
	 * @return
	 */
	@GET
	@Produces("application/xml")
	public String getXml() {
		return "<xml/>";
	}

	/**
	 * <pre>
	 * {@code curl -v -H "Accept: application/json" http://localhost:8080/asw2016-demo-webapp/resources/content-negotiation }
	 * </pre>
	 * 
	 * @return
	 */
	@GET
	@Produces("application/json")
	public String getJson() {
		return "{\"json\":\"true\"}";
	}
	
	/**
	 * <pre>
	 * {@code curl -v -H "Content-Type: application/xml" -d "<data/>"  http://localhost:8080/asw2016-demo-webapp/resources/content-negotiation }
	 * </pre>
	 * 
	 * @return
	 */
@POST
@Consumes(MediaType.APPLICATION_XML)
@Produces(MediaType.TEXT_HTML)
public String consumeXml(String xml){
	return "<pre>" + xml + "</pre>";
}
}

@@ -224,16 +224,20 @@
  * %3Cpre%3E
+%0A * 
 %7B@code c
@@ -261,23 +261,31 @@
 t: *%5C/*%7D
+%0A * 
 %3C/pre%3E%0A
+ * %0A
  * %3Cpre%3E
@@ -401,19 +401,16 @@
 Browser?
-%0A *
  Try wit
@@ -421,16 +421,20 @@
 rome...%0A
+ * %0A
  * @see 
@@ -1133,17 +1133,16 @@
 %22%7D%22;%0A%09%7D%0A
-%09
 %0A%09/**%0A%09 
@@ -1328,14 +1328,16 @@
  */%0A
+%09
 @POST%0A
+%09
 @Con
@@ -1369,16 +1369,17 @@
 ON_XML)%0A
+%09
 @Produce
@@ -1401,16 +1401,17 @@
 T_HTML)%0A
+%09
 public S
@@ -1438,18 +1438,20 @@
 ing xml)
+ 
 %7B%0A
+%09
 %09return 
@@ -1476,12 +1476,13 @@
 /pre%3E%22;%0A
+%09
 %7D%0A%7D%0A

Revise ContentNegotiationExampleResource