public Task StartAsync()

in client/Apache.ShenYu.AspNetCore/Services/ShenyuStartupService.cs [69:150]


        public Task StartAsync(CancellationToken cancellationToken)
        {
            this._hostApplicationLifetime.ApplicationStarted.Register(async () =>
            {
                await this._shenyuRegister.Init(this._shenyuOptions.Value);

                var addresses = this.GetAddresses();
                var ipAddresses = GetIpAddresses(addresses);
                
                var rpcTypes = this._shenyuOptions.Value.Client.ClientType
                    .Split(',')
                    .Select(type => type.Trim())
                    .ToList();
                foreach (var address in ipAddresses)
                {
                    var uri = new Uri(address);
                    if (!rpcTypes.Contains(uri.Scheme))
                    {
                        continue;
                    }

                    // if isFull equals to true, set the whole application as proxy
                    if (this._shenyuOptions.Value.Client.IsFull)
                    {
                        await this._shenyuRegister.PersistInterface(this.BuildMetadataDto(null, address));
                    }
                    else
                    {
                        var controllerFeature = new ControllerFeature();
                        this._partManager.PopulateFeature(controllerFeature);

                        var controllers = controllerFeature.Controllers;
                        // traverse all actions
                        foreach (var controller in controllers)
                        {
                            var shenyuClientAttr = controller.GetCustomAttribute<ShenyuClientAttribute>();
                            if (shenyuClientAttr != null && shenyuClientAttr.Path.Contains("**"))
                            {
                                // proxy the whole controller
                                await this._shenyuRegister.PersistInterface(this.BuildMetadataDto(shenyuClientAttr.Path,
                                    address));
                                continue;
                            }

                            var routeAttr = controller.GetCustomAttribute<RouteAttribute>();
                            if (routeAttr == null)
                            {
                                continue;
                            }

                            var basePath = this.GetPath(shenyuClientAttr, routeAttr, controller.Name);

                            var methods = controller.GetMethods();
                            foreach (var method in methods)
                            {
                                // only support action with one HttpMethodAttribute for now
                                var methodRouteAttr = method.GetCustomAttribute<HttpMethodAttribute>();
                                if (methodRouteAttr == null)
                                {
                                    continue;
                                }

                                var methodShenyuAttr = method.GetCustomAttribute<ShenyuClientAttribute>();
                                var path = this.GetPath(methodShenyuAttr, methodRouteAttr);

                                var wholePath = path == null ? basePath : Path.Combine(Constants.PathSeparator, basePath, path.TrimStart(Convert.ToChar(Constants.PathSeparator)));
                                //fix if wholePath like "path01\\path02"
                                if(wholePath != null && wholePath.Contains(Constants.DoubleSlash)){
                                    wholePath = wholePath.Replace(Constants.DoubleSlash, Constants.PathSeparator);
                                }

                                await this._shenyuRegister.PersistInterface(this.BuildMetadataDto(wholePath, address));
                            }
                        }
                    }

                    await this._shenyuRegister.PersistURI(this.BuildUriRegisterDto(address));
                }
            });

            return Task.CompletedTask;
        }