Created
December 13, 2018 15:16
-
-
Save eldermoraes/8ba0e1af831a2a0164aa3b72d5119a9b to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@Path("app2") | |
public class App2 { | |
@Inject | |
private Auth auth; | |
@GET | |
public Response helloWorld(String token) { | |
if (!auth.isLogged(token)) { | |
throw new WebApplicationException(Response.Status.UNAUTHORIZED); | |
} | |
return Response.ok("Hello World. Welcome to App2!").build(); | |
} | |
@POST | |
@Consumes("application/x-www-form-urlencoded") | |
public Response helloWorld(@FormParam("login") String login, @FormParam("password") String password) { | |
if (Objects.isNull(login) || Objects.isNull(password)) { | |
throw new WebApplicationException(Response.Status.INTERNAL_SERVER_ERROR); | |
} | |
String token = auth.login(login, password); | |
return Response | |
.ok("Hello World. Welcome to App2!") | |
.header("token", token) | |
.build(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment