我想做的是:
以下是我的代码:
public boolean preHandle(HttpServletRequest request, HttpServletResponse response, Object handler) {
LOG.info("#### Starting TokenValidateInterceptor.preHandle ####");
LOG.info("apikeyAttribute-->" + request.getAttribute("apiKey"); //coming as a blank
LOG.info("apikeyHeader-->" + request.getHeader("apiKey"));//coming as a blank
if (StringUtils.isBlank(apiKey)) {
if (!request.getRequestURI().endsWith("/")) {
try {
response.sendError(401, ("Unauthorized: Access is denied due to invalid credentials."));
} catch (IOException e) {
LOG.error("##### IOException occured at TokenValidateInterceptor.preHandle() #####", e);
} catch (Exception e) {
LOG.error("##### Generic Exception occured at TokenValidateInterceptor.preHandle() #####,e");
}
//This block is getting executed but still its calling the other microservice
return false;
} else {
return true;
}
}
我在这里面临两个问题 -
postman
请参阅附件图片, The way I am calling my gateway