-
-
Notifications
You must be signed in to change notification settings - Fork 5
Service method path mapping
The JaxRs annotation @Path
is used to map each service method to an endpoint in the service alongside the http method, the path defined in the service method definition will be appended to matched service root of that service and can have variable parameters.
for example for the service :
@RequestFactory
public interface MoviesService {
@Path("library/movies/:movieName")
@GET
Movie getMovieByName(@PathParam("movieName") String movieName);
@Path("library/movies")
@GET
List<Movie> listMovies();
@Path("library/movies/:name")
@PUT
void updateMovie(@BeanParam @RequestBody Movie movie);
}
the listMovies
method will produce an http request to the following endpoint :
http://localhost:8080/service/library/movies
we can define a variable parameter in the method path by adding :
before the name of the parameter or surround it with {}
, the parameter name will be matched with the method argument name for replacement
for example : calling getMovieByName
and pass the movie name hulk
as argument will result in the following http request path :
http://localhost:8080/service/library/movies/hulk
if we are passing a request body in the method argument we can use that request properties to replace path variable parameters, the variable path parameter name will be match with the property name from the request pojo.
- Home
- Quick start
- Sharing clients
-
Configuration
- Locating resource classes
- Service root
- Resource root
- Http methods
- Service method path mapping
- Service path
- Query parameters
- Path parameters
- Header parameters
- Date format
- Request body
- Request and Response mapping
- Produces and Consumes
- Success codes
- Timeout and maximum retries
- With credentials
- Custom request URL
- Global interceptors
- Default failed response handler
- Interface inheritance
- Multipart form data