Jersey framework override contoller methods or REST request filtering
I need to implement a controller for processing requests whith filter use
Jersey framework. For example:
.../myservice/book - display a list of all books.
.../myservice/book?chapter=1,5 - display 1 and 5 books chapters.
.../myservice/book?page=10,50 - display 10 and 50 books pages.
.../myservice/book?chapter=1,5&page=10,50 - display 1 and 5 books chapters
and only 10 and 50 book pages.
I can't use .../myservice/book/chapter/1,5/page/10,50, because possible
situation: .../myservice/book/7 - display book 7 and filters described
above can be applied here. Is it possible to implement it in this way:
public class TestController {
@Path("/book")
@GET
public Object getBook() {
// return a list of all books
}
public Object getBook(@QueryParam("chapter") String chapter) {
// return books chapters
}
public Object getBook(@QueryParam("chapter") String page) {
// return books pages
}
public Object getBook(@QueryParam("chapter") String page,
@QueryParam("page") String page) {
// return books chapters and pages
}
}
Or to add all kinds of filters in one method and verify the presence of a
large number of conditions?
No comments:
Post a Comment