use of spark.FilterImpl in project spark by perwendel.
the class AfterFilters method execute.
static void execute(RouteContext context) throws Exception {
Object content = context.body().get();
List<RouteMatch> matchSet = context.routeMatcher().findMultiple(HttpMethod.after, context.uri(), context.acceptType());
for (RouteMatch filterMatch : matchSet) {
Object filterTarget = filterMatch.getTarget();
if (filterTarget instanceof FilterImpl) {
if (context.requestWrapper().getDelegate() == null) {
Request request = RequestResponseFactory.create(filterMatch, context.httpRequest());
context.requestWrapper().setDelegate(request);
} else {
context.requestWrapper().changeMatch(filterMatch);
}
context.responseWrapper().setDelegate(context.response());
FilterImpl filter = (FilterImpl) filterTarget;
filter.handle(context.requestWrapper(), context.responseWrapper());
String bodyAfterFilter = context.response().body();
if (bodyAfterFilter != null) {
content = bodyAfterFilter;
}
}
}
context.body().set(content);
}
use of spark.FilterImpl in project spark by perwendel.
the class BeforeFilters method execute.
static void execute(RouteContext context) throws Exception {
Object content = context.body().get();
List<RouteMatch> matchSet = context.routeMatcher().findMultiple(HttpMethod.before, context.uri(), context.acceptType());
for (RouteMatch filterMatch : matchSet) {
Object filterTarget = filterMatch.getTarget();
if (filterTarget instanceof FilterImpl) {
Request request = RequestResponseFactory.create(filterMatch, context.httpRequest());
FilterImpl filter = (FilterImpl) filterTarget;
context.requestWrapper().setDelegate(request);
context.responseWrapper().setDelegate(context.response());
filter.handle(context.requestWrapper(), context.responseWrapper());
String bodyAfterFilter = context.response().body();
if (bodyAfterFilter != null) {
content = bodyAfterFilter;
}
}
}
context.body().set(content);
}
use of spark.FilterImpl in project spark by perwendel.
the class AfterAfterFilters method execute.
static void execute(RouteContext context) throws Exception {
Object content = context.body().get();
List<RouteMatch> matchSet = context.routeMatcher().findMultiple(HttpMethod.afterafter, context.uri(), context.acceptType());
for (RouteMatch filterMatch : matchSet) {
Object filterTarget = filterMatch.getTarget();
if (filterTarget instanceof FilterImpl) {
if (context.requestWrapper().getDelegate() == null) {
Request request = RequestResponseFactory.create(filterMatch, context.httpRequest());
context.requestWrapper().setDelegate(request);
} else {
context.requestWrapper().changeMatch(filterMatch);
}
context.responseWrapper().setDelegate(context.response());
FilterImpl filter = (FilterImpl) filterTarget;
filter.handle(context.requestWrapper(), context.responseWrapper());
String bodyAfterFilter = context.response().body();
if (bodyAfterFilter != null) {
content = bodyAfterFilter;
}
}
}
context.body().set(content);
}
Aggregations