use of com.netflix.zuul.context.RequestContext in project micro-continuum by codefinity.
the class CustomZuulFilter method run.
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
ctx.getRequest().setAttribute("custom-attribute", "custom-value");
System.out.println("Zuul filter run method");
return null;
}
use of com.netflix.zuul.context.RequestContext in project tutorials by eugenp.
the class TokenRelayFilter method run.
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
Set<String> headers = (Set<String>) ctx.get("ignoredHeaders");
// We need our JWT tokens relayed to resource servers
headers.remove("authorization");
return null;
}
use of com.netflix.zuul.context.RequestContext in project tutorials by eugenp.
the class AccessControlFilter method run.
@Override
public Object run() {
RequestContext ctx = RequestContext.getCurrentContext();
ctx.setResponseStatusCode(HttpStatus.FORBIDDEN.value());
if (ctx.getResponseBody() == null && !ctx.getResponseGZipped()) {
ctx.setSendZuulResponse(false);
}
log.debug("Access Control: filtered unauthorized access on endpoint {}", ctx.getRequest().getRequestURI());
return null;
}
use of com.netflix.zuul.context.RequestContext in project tutorials by eugenp.
the class RateLimitingFilter method apiLimitExceeded.
private void apiLimitExceeded() {
RequestContext ctx = RequestContext.getCurrentContext();
ctx.setResponseStatusCode(HttpStatus.TOO_MANY_REQUESTS.value());
if (ctx.getResponseBody() == null) {
ctx.setResponseBody("API rate limit exceeded");
ctx.setSendZuulResponse(false);
}
}
use of com.netflix.zuul.context.RequestContext in project tutorials by eugenp.
the class SwaggerBasePathRewritingFilter method run.
@Override
public Object run() {
RequestContext context = RequestContext.getCurrentContext();
if (!context.getResponseGZipped()) {
context.getResponse().setCharacterEncoding("UTF-8");
}
String rewrittenResponse = rewriteBasePath(context);
context.setResponseBody(rewrittenResponse);
return null;
}
Aggregations