Skip to content

Success codes

Ahmad K. Bawaneh edited this page Mar 16, 2020 · 3 revisions

Success codes

By default status codes 200,201,202,203,204 are considered a success for all requests, if we need to change this behavior we can change this for a single request using the @SuccessCodes annotation.

@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
    @SuccessCodes({200})
    void updateMovie(@beanParam @RequestBody Movie movie);
}

now updateMethod will only be considered success if the response status code is 200.