package hello;

import javax.ws.rs.GET;
import javax.ws.rs.HeaderParam;
import javax.ws.rs.MatrixParam;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.QueryParam;

@Path("/param")
public class Parametry {
	// http://localhost:8080/PC20-Rest-1.0/param/query?x=Ala&y=Ola
	@GET
	@Path("/query")
	public String query(@QueryParam("x") String x, @QueryParam("y") String y) {
		return "x = " + x + ", y = " +y;
	}
	
	// http://localhost:8080/PC20-Rest-1.0/param/matrix;x=Ala;y=Ola
	@GET
	@Path("/matrix")
	public String matrix(@MatrixParam("x") String x, @MatrixParam("y") String y) {
		return "x = " + x + ", y = " +y;
	}
	
	// http://localhost:8080/PC20-Rest-1.0/param/path/Ala/Ola
	@GET
	@Path("/path/{x}/{y}")
	public String path(@PathParam("x") String x, @PathParam("y") String y) {
		return "x = " + x + ", y = " +y;
	}

	// http://localhost:8080/PC20-Rest-1.0/param/re1234gucio
	@GET
	@Path("/re{x:\\d+}{y}")
	public String re(@PathParam("x") String x, @PathParam("y") String y) {
		return "cyfry: " + x + ", reszta: " +y;
	}
	
	// http://localhost:8080/PC20-Rest-1.0/param/header
	@GET
	@Path("/header")
	public String head(@HeaderParam("User-Agent") String x, @HeaderParam("Accept") String y) {
		return "x = " + x + ", y = " +y;
	}
	
}
