java - Call more than post method in same resource in RestLet framework -


i want more 1 post method in same resource class of restlet framework shown below:

public class myclass extends serverresource {      private logger log = logger.getlogger(loginresource.class.getname());      @post     public representation createuser(final representation representation) throws ioexception {         ..........................         ................................     }      /**       * class in creating person.       * @return representation representation       * @param representation representation       * @throws ioexception ioexception       */     @post     public representation createalluser(final representation representation) throws ioexception {         ...............         ...............................         return new jacksonrepresentation<>("success");     } } 

how can it? please provide solution according problem. please me.

i don't know want do. isn't clear question way choose method use handle post request (call 1 or annotated method). want use query parameter, header or in payload?

for query parameter, can use @ annotation level, described below:

@post("?myparam=something") public representation createuser(final representation representation) throws ioexception { 

for other cases, think should use single annotated method handles routing right handling method. if want use custom header x-action:

@post public representation handleaction(representation representation)                                      throws ioexception {     series<header> headers = (series<header>)        getrequestattributes().get("org.restlet.http.headers");      string actionheader = headers.getfirstvalue("x-action", "single");     if ("single".equals(actionheader)) {         return handleaction1(representation);     } else {         return handleaction2(representation);     } } 

in addition, can have @ link way implement multi actions method post rest , restlet: https://templth.wordpress.com/2015/03/20/handling-multiple-actions-for-a-post-method/.

hope helps you, thierry


Comments

Popular posts from this blog

android - MPAndroidChart - How to add Annotations or images to the chart -

javascript - Add class to another page attribute using URL id - Jquery -

firefox - Where is 'webgl.osmesalib' parameter? -