1 package com.atlassian.plugins.rest.sample.expansion.resource;
2
3 import javax.ws.rs.*;
4 import javax.ws.rs.core.Context;
5 import static javax.ws.rs.core.MediaType.APPLICATION_JSON;
6 import static javax.ws.rs.core.MediaType.APPLICATION_XML;
7 import javax.ws.rs.core.Response;
8 import javax.ws.rs.core.UriBuilder;
9 import javax.ws.rs.core.UriInfo;
10
11
12
13
14
15
16
17 @Path("/player")
18 @Consumes({APPLICATION_XML, APPLICATION_JSON})
19 @Produces({APPLICATION_XML, APPLICATION_JSON})
20 public class PlayerResource
21 {
22 @Context
23 private UriInfo uriInfo;
24
25 @GET
26 @Path("/{id}")
27 public Response getPlayer(@PathParam("id") Integer id) throws Exception
28 {
29 return Response.ok(DataStore.getInstance().getPlayer(id, getPlayerUriBuilder(uriInfo))).build();
30 }
31
32 static UriBuilder getPlayerUriBuilder(UriInfo uriInfo)
33 {
34 return uriInfo.getBaseUriBuilder().path("player").path("{id}");
35 }
36 }
37