Skip to content

Service path

Ahmad K. Bawaneh edited this page Dec 28, 2019 · 2 revisions

Service path

the @Path annotation provides the ability to define a shared path for all service method.

Sample

instead of

@RequestFactory
public interface MoviesService {

    @Path("library/movies/:movieName")
    @GET
    Movie getMovieByName(String movieName);

    @Path("library/movies")
    @GET
    List<Movie> listMovies();

    @Path("library/movies/:name")
    @PUT
    void updateMovie(@RequestBody Movie movie);
}

we can define it like this

@RequestFactory
@Path("library")
public interface MoviesService {

    @Path("/movies/:movieName")
    @GET
    Movie getMovieByName(String movieName);

    @Path("/movies")
    @GET
    List<Movie> listMovies();

    @Path("/movies/:name")
    @PUT
    void updateMovie(@RequestBody Movie movie);
}