in core/src/main/java/org/apache/servicecomb/core/filter/impl/ContextMapperFilter.java [59:83]
public CompletableFuture<Response> onFilter(Invocation invocation, FilterNode nextNode) {
GovernanceRequestExtractor request = MatchType.createGovHttpRequest(invocation);
Mapper mapper = mapperHandler.getActuator(request);
if (mapper == null || CollectionUtils.isEmpty(mapper.target())) {
return nextNode.onFilter(invocation);
}
Map<String, String> properties = mapper.target();
properties.forEach((k, v) -> {
if (StringUtils.isEmpty(v)) {
return;
}
if ("$U".equals(v)) {
invocation.addContext(k, request.apiPath());
} else if ("$M".equals(v)) {
invocation.addContext(k, request.method());
} else if (v.startsWith("$H{") && v.endsWith("}")) {
invocation.addContext(k, request.header(v.substring(3, v.length() - 1)));
} else if (v.startsWith("$Q{") && v.endsWith("}")) {
invocation.addContext(k, request.query(v.substring(3, v.length() - 1)));
} else {
invocation.addContext(k, v);
}
});
return nextNode.onFilter(invocation);
}