use of com.netflix.zuul.context.RequestContext in project paascloud-master by paascloud.
the class AuthHeaderFilter method run.
/**
* Run object.
*
* @return the object
*/
@Override
public Object run() {
log.info("AuthHeaderFilter - 开始鉴权...");
RequestContext requestContext = RequestContext.getCurrentContext();
try {
doSomething(requestContext);
} catch (Exception e) {
log.error("AuthHeaderFilter - [FAIL] EXCEPTION={}", e.getMessage(), e);
throw new BusinessException(ErrorCodeEnum.UAC10011041);
}
return null;
}
use of com.netflix.zuul.context.RequestContext in project incubator-servicecomb-java-chassis by apache.
the class TracePostZuulFilter method run.
@Override
public Object run() {
RequestContext context = RequestContext.getCurrentContext();
((SpanInScope) context.getRequest().getAttribute(SpanInScope.class.getName())).close();
clientHandler.handleReceive(context.getResponse(), null, tracer.currentSpan());
log.debug("Closed span {} for {}", tracer.currentSpan(), context.getRequest().getMethod());
return null;
}
use of com.netflix.zuul.context.RequestContext in project incubator-servicecomb-java-chassis by apache.
the class TracePreZuulFilter method runFilter.
@Override
public ZuulFilterResult runFilter() {
RequestContext ctx = RequestContext.getCurrentContext();
Span span = clientHandler.handleSend(injector, ctx);
saveHeadersAsInvocationContext(ctx, span);
SpanInScope scope = tracer.withSpanInScope(span);
log.debug("Generated tracing span {} for {}", span, ctx.getRequest().getMethod());
ctx.getRequest().setAttribute(SpanInScope.class.getName(), scope);
ZuulFilterResult result = super.runFilter();
log.debug("Result of Zuul filter is [{}]", result.getStatus());
if (ExecutionStatus.SUCCESS != result.getStatus()) {
log.debug("The result of Zuul filter execution was not successful thus will close the current span {}", span);
clientHandler.handleReceive(ctx.getResponse(), result.getException(), span);
scope.close();
}
return result;
}
use of com.netflix.zuul.context.RequestContext in project incubator-servicecomb-java-chassis by apache.
the class ContextHeaderZuulFilter method run.
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
ctx.addZuulRequestHeader(SRC_MICROSERVICE, microserviceName);
saveHeadersAsInvocationContext(ctx);
return null;
}
use of com.netflix.zuul.context.RequestContext in project microservices by pwillhan.
the class RateLimitingZuulFilter method run.
@Override
public Object run() {
try {
RequestContext currentContext = RequestContext.getCurrentContext();
HttpServletResponse response = currentContext.getResponse();
if (!this.rateLimiter.tryAcquire()) {
response.setStatus(HttpStatus.TOO_MANY_REQUESTS.value());
response.getWriter().append(HttpStatus.TOO_MANY_REQUESTS.getReasonPhrase());
currentContext.setSendZuulResponse(false);
}
} catch (IOException e) {
ReflectionUtils.rethrowRuntimeException(e);
}
return null;
}
Aggregations