private CachedFunctionInfo AnalyzeFunctionControllerType(Type controllerType) { var method = FindOnCallMethod(controllerType); if (method == null) { return(null); } var path = ResolveRoute(controllerType); if (!FunctionRouteParser.IsValidRpcRoute(path, rpcServerConfiguration)) { return(null); } var name = FunctionRouteParser.GetFunctionName(path, rpcServerConfiguration); if (!FunctionRouteParser.IsValidFunctionName(name)) { return(null); } var info = new CachedFunctionInfo { CallMethod = method, Name = name, Path = path, IsCallMethodAsync = IsMethodAsync(method), RequiresAuthorization = FunctionRequiresAuthorization(method), }; return(info); }
public async Task InvokeAsync(HttpContext context) { var request = context.Request; var response = context.Response; var headers = request.Headers; var pathStr = request.Path.Value; if (!FunctionRouteParser.IsValidRpcRoute(pathStr, rpcService.Configuration)) { await next.Invoke(context); return; } if (!CheckRpcHeader(headers)) { await SendErrorOutput(response, RpcErrorCode.IncompatibleRpcVersion); return; } var fName = FunctionRouteParser.GetFunctionName(pathStr, rpcService.Configuration); var functionInfo = rpcService.GetCachedFunctionInfo(fName); if (functionInfo == null) { await SendErrorOutput(response, RpcErrorCode.FunctionNotFound); return; } context.Items["rpcService"] = rpcService; context.Items["functionInfo"] = functionInfo; await next.Invoke(context); }