1
我新的REST API目前我工作的一個項目,我有2個資源:REST API設計與相關資源
- 項目
- 客戶
現在爲這個做了我需要創建2個資源類,如下所示或單個資源類。
@Path("/v1/projects")
public interface ProjectResource {
@POST
public Respone add(Project project)
@DELETE
public Respone delete(Project project)
@PUT
public Respone update(Project project)
}
@Path("/v1/projects/{projectId}/client")
public interface ClientResource {
@POST
public Respone add(Client client)
@DELETE
public Respone delete(Client client)
@PUT
public Respone update(Client client)
}
或單一的資源類的所有方法
@Path("/v1/projects")
public interface ProjectResource {
@POST
public Respone add(Project project)
@DELETE
public Respone delete(Project project)
@PUT
public Respone update(Project project)
@Path("/{projectId}/client")
@POST
public Respone add(Client client)
@Path("/{projectId}/client")
@DELETE
public Respone delete(Client client)
@Path("/{projectId}/client")
@PUT
public Respone update(Client client)
}