com.jslsolucoes.jax.rs.server.ee.response.Responses Maven / Gradle / Ivy
package com.jslsolucoes.jax.rs.server.ee.response;
import java.net.URI;
import java.util.Collection;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.Response.Status;
import javax.ws.rs.core.UriInfo;
public class Responses {
public static Response status(Status status, Object object) {
return Response.status(status).entity(object).build();
}
public static Response index(String message) {
return ok(new IndexResponse(message));
}
public static Response notFound(String message) {
return status(Status.NOT_FOUND, new NotFoundResponse(message));
}
public static Response badRequest(Collection messages) {
return status(Status.BAD_REQUEST, new BadRequestResponse(messages));
}
public static Response ok(Object object) {
return status(Status.OK,object);
}
public static Response created(UriInfo uriInfo, Long id) {
return Response.created(location(uriInfo, id)).build();
}
private static URI location(UriInfo uriInfo, Long id) {
return uriInfo.getAbsolutePathBuilder().path(Long.toString(id)).build();
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy