Created
May 30, 2019 03:05
-
-
Save xring/867d0b7e56815fc38f812aefd88b72de 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
@RestController | |
@Slf4j | |
public class AuthController { | |
@GetMapping("/") | |
public void auth(HttpServletRequest request, HttpServletResponse response) { | |
Map<String, String> headers = new HashMap<>(); | |
Enumeration headerNames = request.getHeaderNames(); | |
while (headerNames.hasMoreElements()) { | |
String key = (String) headerNames.nextElement(); | |
String value = request.getHeader(key); | |
headers.put(key, value); | |
} | |
String authT = headers.get("authorization"); | |
if (StringUtils.isEmpty(authT)) { | |
response.setStatus(HttpStatus.UNAUTHORIZED.value()); | |
return; | |
} | |
response.setStatus(HttpStatus.OK.value()); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment