use of com.netflix.zuul.context.RequestContext in project spring-boot-admin by codecentric.
the class ApplicationHeadersFilter method run.
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
String requestURI = this.urlPathHelper.getPathWithinApplication(ctx.getRequest());
ApplicationRoute route = this.routeLocator.getMatchingRoute(requestURI);
if (route != null) {
HttpHeaders headers = headersProvider.getHeaders(route.getApplication());
for (Entry<String, List<String>> header : headers.entrySet()) {
ctx.addZuulRequestHeader(header.getKey(), header.getValue().get(0));
}
}
return null;
}
use of com.netflix.zuul.context.RequestContext in project zuul by Netflix.
the class ZuulServlet method service.
@Override
public void service(javax.servlet.ServletRequest servletRequest, javax.servlet.ServletResponse servletResponse) throws ServletException, IOException {
try {
init((HttpServletRequest) servletRequest, (HttpServletResponse) servletResponse);
// Marks this request as having passed through the "Zuul engine", as opposed to servlets
// explicitly bound in web.xml, for which requests will not have the same data attached
RequestContext context = RequestContext.getCurrentContext();
context.setZuulEngineRan();
try {
preRoute();
} catch (ZuulException e) {
error(e);
postRoute();
return;
}
try {
route();
} catch (ZuulException e) {
error(e);
postRoute();
return;
}
try {
postRoute();
} catch (ZuulException e) {
error(e);
return;
}
} catch (Throwable e) {
error(new ZuulException(e, 500, "UNHANDLED_EXCEPTION_" + e.getClass().getName()));
} finally {
RequestContext.getCurrentContext().unset();
}
}
use of com.netflix.zuul.context.RequestContext in project SpringCloudDemo by RickJou.
the class PostFilter method run.
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletRequest request = ctx.getRequest();
Object accessToken = request.getParameter("accessToken");
if (accessToken == null) {
ctx.setSendZuulResponse(false);
ctx.setResponseStatusCode(401);
}
log.info("post filter......");
return null;
}
use of com.netflix.zuul.context.RequestContext in project SpringCloudDemo by RickJou.
the class PreFilter method run.
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
HttpServletRequest request = ctx.getRequest();
Object accessToken = request.getParameter("accessToken");
if (accessToken == null) {
ctx.setSendZuulResponse(false);
ctx.setResponseStatusCode(401);
}
log.info("pre filter......");
return null;
}
use of com.netflix.zuul.context.RequestContext in project paascloud-master by paascloud.
the class RenewFilter method run.
/**
* Run object.
*
* @return the object
*/
@Override
public Object run() {
log.info("RenewFilter - token续租...");
RequestContext requestContext = RequestContext.getCurrentContext();
try {
doSomething(requestContext);
} catch (Exception e) {
log.error("RenewFilter - token续租. [FAIL] EXCEPTION={}", e.getMessage(), e);
throw new BusinessException(ErrorCodeEnum.UAC10011041);
}
return null;
}
Aggregations