package com.javahonk;

import java.util.ArrayList;
import java.util.List;

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


@Path("/user")
public class HelloWorld {
	
	private static List<User> users = new ArrayList<User>();
	@POST
	@Path("/add")
	@Consumes(MediaType.APPLICATION_JSON)
	@Produces(MediaType.TEXT_HTML)
	public Response addUser(User us) {
		users.add( us );
		return Response.status(200).entity("Successfully added below user: </br>" + us.getName()).build();
	}	

	@GET 	            
	@Path("/search")
	@Produces(MediaType.APPLICATION_JSON)
	public List<User> getUser(@PathParam("userId") String id){
		return users;
	}
}