[JBoss JIRA] (FORGE-2177) Being able to create a new REST endpoint
by Antonio Goncalves (JIRA)
[ https://issues.jboss.org/browse/FORGE-2177?page=com.atlassian.jira.plugin... ]
Antonio Goncalves updated FORGE-2177:
-------------------------------------
Description:
It would be good to have a command to create a REST endpoint. A command like this :
{code}
rest-new-endpoint --named MyEndpoint
{code}
Would generate
{code}
@Path("/myEndpoint")
public class CustomerEndpoint
{
}
{code}
Changing the path would be :
{code}
rest-new-endpoint --named MyEndPoint --path endpoint
{code}
…
[View More]This would generate :
{code}
@Path("/endpoint")
public class CustomerEndpoint
{
}
{code}
The command also allows to generate several default methods (get, post, put, delete) with default mime type and so on :
{code}
rest-new-endpoint --named MyEndPoin --methods GET POST DELETE
{code}
This would generate :
{code}
@Path("/myEndpoint")
public class CustomerEndpoint
{
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response doGet()
{
return Response.noContent().build();
}
@POST
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response doPost()
{
return Response.noContent().build();
}
}
{code}
Also, a REST configuration class needs to be creates, such as :
{code}
@ApplicationPath("/rest")
public class RestApplication extends Application
{
}
{code}
was:
It would be good to have a command to create a REST endpoint. A command like this :
{code}
rest-new-endpoint --named MyEndpoint
{code}
Would generate
{code}
@Path("/myEndpoint")
public class CustomerEndpoint
{
}
{code}
Changing the path would be :
{code}
rest-new-endpoint --named MyEndPoint --path endpoint
{code}
This would generate :
{code}
@Path("/endpoint")
public class CustomerEndpoint
{
}
{code}
The command also allows to generate several default methods (get, post, put, delete) with default mime type and so on :
{code}
rest-new-endpoint --named MyEndPoin --methods GET POST DELETE
{code}
This would generate :
{code}
@Path("/myEndpoint")
public class CustomerEndpoint
{
}
{code}
Also, a REST configuration class needs to be creates, such as :
{code}
@ApplicationPath("/rest")
public class RestApplication extends Application
{
@GET
@Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response doGet()
{
return Response.noContent().build();
}
@POST
@Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
public Response doPost()
{
return Response.noContent().build();
}
}
{code}
> Being able to create a new REST endpoint
> ----------------------------------------
>
> Key: FORGE-2177
> URL: https://issues.jboss.org/browse/FORGE-2177
> Project: Forge
> Issue Type: Sub-task
> Components: Java EE
> Affects Versions: 2.13.0.Final
> Reporter: Antonio Goncalves
> Labels: Starter
> Fix For: 2.x Future
>
>
> It would be good to have a command to create a REST endpoint. A command like this :
> {code}
> rest-new-endpoint --named MyEndpoint
> {code}
> Would generate
> {code}
> @Path("/myEndpoint")
> public class CustomerEndpoint
> {
> }
> {code}
> Changing the path would be :
> {code}
> rest-new-endpoint --named MyEndPoint --path endpoint
> {code}
> This would generate :
> {code}
> @Path("/endpoint")
> public class CustomerEndpoint
> {
> }
> {code}
> The command also allows to generate several default methods (get, post, put, delete) with default mime type and so on :
> {code}
> rest-new-endpoint --named MyEndPoin --methods GET POST DELETE
> {code}
> This would generate :
> {code}
> @Path("/myEndpoint")
> public class CustomerEndpoint
> {
> @GET
> @Produces({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
> public Response doGet()
> {
> return Response.noContent().build();
> }
> @POST
> @Consumes({MediaType.APPLICATION_XML, MediaType.APPLICATION_JSON})
> public Response doPost()
> {
> return Response.noContent().build();
> }
> }
> {code}
> Also, a REST configuration class needs to be creates, such as :
> {code}
> @ApplicationPath("/rest")
> public class RestApplication extends Application
> {
> }
> {code}
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
[View Less]