This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import javax.ws.rs.*; | |
import javax.ws.rs.core.*; | |
/** | |
* | |
*@author Gokhan | |
*/ | |
@Path("orders") | |
public class OrderService{ | |
@GET | |
@Path("{order Id:\\d+}/items/{itemsId:[a-z]\\d{2,3}}") | |
public Response getOrderItemByItemId(@PathParam("orderId") String orderId, | |
@PathParam("itemId") String itemId){ | |
return Response.status(Response.Status.OK).entity("order id:"+orderId)+ | |
"and item id: " +itemId).build(); | |
} | |
@GET | |
@Path("{orderId}/items/{itemsId}") | |
public Response getInvalidOrderItemByItemId(@PathParam("orderId") String orderId, | |
@PathParam("itemId") String itemId){ | |
return Response.status(Response.Status.BAD_REQUEST).entity("The requested order id or item id are | |
not valid order id :"+orderId)+ | |
"and item id: " +itemId).build(); | |
} | |
} | |
Wireshark'ın genel görünümü
İlk isteğimiz formatımıza uygun olduğu için OK mesajı ikinci isteğimiz ise uygun olmadığı için BAD REQUEST mesajını aldık.Wireshark ağınızda akan paketleri inceleyebilirsiniz.Bir sonraki yazımızda görüşmek üzere.Sağlıcakla kalın...
Hiç yorum yok:
Yorum Gönder