mardi 16 juin 2015

JAX-RS @FormParam one time for all methods

I am developing Java "JAX-RS" Web Services for books and contents. There will be 100s of URLs something similar ...

http://ift.tt/1R5qwzy

http://ift.tt/1R5qwzA

...

http://ift.tt/1Tr4z27

To fetch the chapter content user needed to POST authToken, which I validate in server and return content or error. The sample code ...

@Path("/book1")
public class Book1 {

    @Path("/chapter/{cNum}")
    public String getMedias(
            @PathParam("cNum") String cNum, 
            @FormParam("authToken") String authToken) {
        // so here I validate the authToken
        return "bla bla!";
    }
}

This works perfectly. But I repeated @FormParam("authToken") in all 100s of methods like above. Is there a way that I can check only one time somewhere and remove from all methods? Thank you so much!

Aucun commentaire:

Enregistrer un commentaire