Add an authority header to HandlerRegistry.lookupMethod

This commit is contained in:
Carl Mastrangelo 2015-09-02 15:29:21 -07:00
parent 2aecb6f02b
commit 28d51c5e3e
2 changed files with 19 additions and 2 deletions

View File

@ -45,9 +45,23 @@ public abstract class HandlerRegistry {
* Lookup a {@link ServerMethodDefinition} by its fully-qualified name.
*
* @param methodName to lookup {@link ServerMethodDefinition} for.
* @param authority the authority for the desired method (to do virtual hosting). If {@code null}
* the first matching method will be returned.
* @return the resolved method or {@code null} if no method for that name exists.
*/
@Nullable
public abstract ServerMethodDefinition<?, ?> lookupMethod(String methodName);
public abstract ServerMethodDefinition<?, ?> lookupMethod(
String methodName, @Nullable String authority);
/**
* Lookup a {@link ServerMethodDefinition} by its fully-qualified name.
*
* @param methodName to lookup {@link ServerMethodDefinition} for.
* @return the resolved method or {@code null} if no method for that name exists.
*/
@Nullable
public final ServerMethodDefinition<?, ?> lookupMethod(String methodName) {
return lookupMethod(methodName, null);
}
}

View File

@ -60,9 +60,12 @@ public final class MutableHandlerRegistryImpl extends MutableHandlerRegistry {
return services.remove(service.getName(), service);
}
/**
* Note: This does not actually honor the authority provided. It will, eventually in the future.
*/
@Override
@Nullable
public ServerMethodDefinition<?, ?> lookupMethod(String methodName) {
public ServerMethodDefinition<?, ?> lookupMethod(String methodName, @Nullable String authority) {
String serviceName = MethodDescriptor.extractFullServiceName(methodName);
if (serviceName == null) {
return null;