use of com.bluenimble.platform.regex.WildcardMatcher in project serverless by bluenimble.
the class ApiImpl method lockup.
protected ApiService lockup(final ApiVerb verb, String[] endpoint) {
if (servicesManager.isEmpty(verb)) {
return null;
}
String path = Lang.SLASH;
if (endpoint != null && endpoint.length > 0) {
path += Lang.join(endpoint, Lang.SLASH);
}
ApiService service = servicesManager.get(verb, path);
if (service != null) {
return service;
}
final String wildcard = path;
final ValueHolder<ApiService> holder = new ValueHolder<ApiService>();
servicesManager.list(new Selector() {
@Override
public boolean select(ApiService service) {
WildcardMatcher matcher = new WildcardMatcher(WildcardCompiler.compile(service.getEndpoint()), wildcard);
if (matcher.find() && service.getVerb().equals(verb)) {
holder.set(service);
return true;
}
return false;
}
});
return holder.get();
}
Aggregations