Cool!

On Tue, Jun 25, 2013 at 10:35 PM, Andrea Del Bene <[email protected]>wrote:

> For my project I've built a resource and a little set of annotation to
> easily expose a REST api which uses JSON as message format. The goal is to
> map custom methods to a specific path and extract their parameters from the
> URL path or from the request body. For example:
>
> public class TestRestResource extends AbstractRestResource {
>     /**
>      * Method invoked for GET requests and URLs like '<resource path>/5'
>      * The id parameter is automatically extracted from URL
>      */
>     @MethodMapping("{id}")
>     public void testMethodInt(int id){
>        ....
>     }
>
>     /**
>      * Method invoked for POST requests and URLs like '<resource path>/5'
>      * The id parameter is automatically extracted from URL
>      * The person parameter is automatically deserialized from request
> body (which is JSON)
>      * The returned object is automatically serialized to JSON and written
> in the response
>      */
>     @MethodMapping(value = "{id}",  httpMethod = HttpMethod.POST)
>     public Person testMethodPostComplex(int id, @JsonBody Person person){
>         ....
>         return person;
>     }
>  ...
>
> I'm porting the code in a public repository here:
> https://github.com/bitstorm/**Wicket-rest-annotations<https://github.com/bitstorm/Wicket-rest-annotations>
>
> I will send a message when I will finish to organize the code.
>
>  Right.
>> The original idea was to create an IRequestHandler that knows how to read
>> such annotations and execute the proper method of IResource passing the
>> correct arguments.
>> But this will take time to implement. So I think it will be easier to just
>> use your favorite rest library and wrap it in WicketSessionFilter to
>> provide access to Application and Session thread locals.
>>
>>
>>
>>
>
> ------------------------------**------------------------------**---------
> To unsubscribe, e-mail: 
> users-unsubscribe@wicket.**apache.org<[email protected]>
> For additional commands, e-mail: [email protected]
>
>

Reply via email to