Say, for example, you have a bunch of functions that all need to check for login validation. To begin with, it looks something like:
public Response createThing(){
if(!validLogin(httpRequest, uriInfo)){
logInvalidLogin();
return Response.status(Response.Status.FORBIDDEN);
}
//Do the function
}
That first block of code exists at the top of every service call, but I don't know how to wrap it into another function because it contains a return statement. I would like something similar to the following:
public Response createThing(){
validateLogin(httpRequest, uriInfo);
//Do the function
}
or
public Response createThing(){
//Implied check somehow?
//Do the function
}
I'm sure there's some pattern or convention out there that people use. Thanks.
Aucun commentaire:
Enregistrer un commentaire