This is an automated email from the ASF dual-hosted git repository.

xiaoyu pushed a commit to branch main
in repository 
https://gitbox.apache.org/repos/asf/incubator-shenyu-client-dotnet.git


The following commit(s) were added to refs/heads/main by this push:
     new 8cde764  add client, asp.net core package and an example (#1)
8cde764 is described below

commit 8cde764acfa1f064217822336b8a48d63d7e8ee6
Author: Han Gao <[email protected]>
AuthorDate: Tue Apr 19 11:19:34 2022 +0800

    add client, asp.net core package and an example (#1)
    
    * add client, asp.net core package and an example
    
    * add apache 2.0 license and remove .editorconfig file
---
 .gitignore                                         | 329 +++++++++++++++++++++
 README.md                                          |  46 +++
 ShenyuClient.sln                                   |  86 ++++++
 .../Apache.ShenYu.AspNetCore.csproj                |  34 +++
 client/Apache.ShenYu.AspNetCore/README.md          |   7 +
 .../Services/ShenyuStartupService.cs               | 193 ++++++++++++
 .../Utils/ShenyuCollectionExtensions.cs            |  48 +++
 .../Apache.ShenYu.Client.Tests.csproj              |  34 +++
 .../Apache.ShenYu.Client.csproj                    |  36 +++
 .../Attibutes/ShenyuClientAttribute.cs             |  37 +++
 .../Models/DTO/MetaDataRegisterDTO.cs              |  57 ++++
 .../Models/DTO/URIRegisterDTO.cs                   |  29 ++
 .../Apache.ShenYu.Client/Options/ShenyuOptions.cs  |  43 +++
 .../Registers/IShenyuRegister.cs                   |  49 +++
 .../Registers/ShenyuHttpRegister.cs                | 137 +++++++++
 client/Apache.ShenYu.Client/Utils/Constants.cs     |  27 ++
 .../AspNetCoreExample/AspNetCoreExample.csproj     |  29 ++
 .../Controllers/TemplateController.cs              |  73 +++++
 .../Controllers/TestController.cs                  |  74 +++++
 .../Controllers/WeatherForecastController.cs       |  73 +++++
 examples/AspNetCoreExample/Program.cs              |  37 +++
 .../Properties/launchSettings.json                 |  31 ++
 examples/AspNetCoreExample/Startup.cs              |  67 +++++
 examples/AspNetCoreExample/WeatherForecast.cs      |  32 ++
 .../AspNetCoreExample/appsettings.Development.json |  22 ++
 examples/AspNetCoreExample/appsettings.json        |  10 +
 26 files changed, 1640 insertions(+)

diff --git a/.gitignore b/.gitignore
index 0df3248..6329edf 100644
--- a/.gitignore
+++ b/.gitignore
@@ -40,3 +40,332 @@ Thumbs.db
 # agent build ignore
 /agent/
 
+## Ignore Visual Studio temporary files, build results, and
+## files generated by popular Visual Studio add-ons.
+##
+## Get latest from 
https://github.com/github/gitignore/blob/master/VisualStudio.gitignore
+
+# User-specific files
+*.suo
+*.user
+*.userosscache
+*.sln.docstates
+
+# User-specific files (MonoDevelop/Xamarin Studio)
+*.userprefs
+
+# Build results
+[Dd]ebug/
+[Dd]ebugPublic/
+[Rr]elease/
+[Rr]eleases/
+x64/
+x86/
+bld/
+[Bb]in/
+[Oo]bj/
+[Ll]og/
+
+# Visual Studio 2015/2017 cache/options directory
+.vs/
+# Uncomment if you have tasks that create the project's static files in wwwroot
+#wwwroot/
+
+# Visual Studio 2017 auto generated files
+Generated\ Files/
+
+# MSTest test Results
+[Tt]est[Rr]esult*/
+[Bb]uild[Ll]og.*
+
+# NUNIT
+*.VisualState.xml
+TestResult.xml
+
+# Build Results of an ATL Project
+[Dd]ebugPS/
+[Rr]eleasePS/
+dlldata.c
+
+# Benchmark Results
+BenchmarkDotNet.Artifacts/
+
+# .NET Core
+project.lock.json
+project.fragment.lock.json
+artifacts/
+
+# StyleCop
+StyleCopReport.xml
+
+# Files built by Visual Studio
+*_i.c
+*_p.c
+*_i.h
+*.ilk
+*.meta
+*.obj
+*.iobj
+*.pch
+*.pdb
+*.ipdb
+*.pgc
+*.pgd
+*.rsp
+*.sbr
+*.tlb
+*.tli
+*.tlh
+*.tmp
+*.tmp_proj
+*.log
+*.vspscc
+*.vssscc
+.builds
+*.pidb
+*.svclog
+*.scc
+
+# Chutzpah Test files
+_Chutzpah*
+
+# Visual C++ cache files
+ipch/
+*.aps
+*.ncb
+*.opendb
+*.opensdf
+*.sdf
+*.cachefile
+*.VC.db
+*.VC.VC.opendb
+
+# Visual Studio profiler
+*.psess
+*.vsp
+*.vspx
+*.sap
+
+# Visual Studio Trace Files
+*.e2e
+
+# TFS 2012 Local Workspace
+$tf/
+
+# Guidance Automation Toolkit
+*.gpState
+
+# ReSharper is a .NET coding add-in
+_ReSharper*/
+*.[Rr]e[Ss]harper
+*.DotSettings.user
+
+# JustCode is a .NET coding add-in
+.JustCode
+
+# TeamCity is a build add-in
+_TeamCity*
+
+# DotCover is a Code Coverage Tool
+*.dotCover
+
+# AxoCover is a Code Coverage Tool
+.axoCover/*
+!.axoCover/settings.json
+
+# Visual Studio code coverage results
+*.coverage
+*.coveragexml
+
+# NCrunch
+_NCrunch_*
+.*crunch*.local.xml
+nCrunchTemp_*
+
+# MightyMoose
+*.mm.*
+AutoTest.Net/
+
+# Web workbench (sass)
+.sass-cache/
+
+# Installshield output folder
+[Ee]xpress/
+
+# DocProject is a documentation generator add-in
+DocProject/buildhelp/
+DocProject/Help/*.HxT
+DocProject/Help/*.HxC
+DocProject/Help/*.hhc
+DocProject/Help/*.hhk
+DocProject/Help/*.hhp
+DocProject/Help/Html2
+DocProject/Help/html
+
+# Click-Once directory
+publish/
+
+# Publish Web Output
+*.[Pp]ublish.xml
+*.azurePubxml
+# Note: Comment the next line if you want to checkin your web deploy settings,
+# but database connection strings (with potential passwords) will be 
unencrypted
+*.pubxml
+*.publishproj
+
+# Microsoft Azure Web App publish settings. Comment the next line if you want 
to
+# checkin your Azure Web App publish settings, but sensitive information 
contained
+# in these scripts will be unencrypted
+PublishScripts/
+
+# NuGet Packages
+*.nupkg
+# The packages folder can be ignored because of Package Restore
+**/[Pp]ackages/*
+# except build/, which is used as an MSBuild target.
+!**/[Pp]ackages/build/
+# Uncomment if necessary however generally it will be regenerated when needed
+#!**/[Pp]ackages/repositories.config
+# NuGet v3's project.json files produces more ignorable files
+*.nuget.props
+*.nuget.targets
+
+# Microsoft Azure Build Output
+csx/
+*.build.csdef
+
+# Microsoft Azure Emulator
+ecf/
+rcf/
+
+# Windows Store app package directories and files
+AppPackages/
+BundleArtifacts/
+Package.StoreAssociation.xml
+_pkginfo.txt
+*.appx
+
+# Visual Studio cache files
+# files ending in .cache can be ignored
+*.[Cc]ache
+# but keep track of directories ending in .cache
+!*.[Cc]ache/
+
+# Others
+ClientBin/
+~$*
+*~
+*.dbmdl
+*.dbproj.schemaview
+*.jfm
+*.pfx
+*.publishsettings
+orleans.codegen.cs
+
+# Including strong name files can present a security risk 
+# (https://github.com/github/gitignore/pull/2483#issue-259490424)
+#*.snk
+
+# Since there are multiple workflows, uncomment next line to ignore 
bower_components
+# (https://github.com/github/gitignore/pull/1529#issuecomment-104372622)
+#bower_components/
+
+# RIA/Silverlight projects
+Generated_Code/
+
+# Backup & report files from converting an old project file
+# to a newer Visual Studio version. Backup files are not needed,
+# because we have git ;-)
+_UpgradeReport_Files/
+Backup*/
+UpgradeLog*.XML
+UpgradeLog*.htm
+ServiceFabricBackup/
+*.rptproj.bak
+
+# SQL Server files
+*.mdf
+*.ldf
+*.ndf
+
+# Business Intelligence projects
+*.rdl.data
+*.bim.layout
+*.bim_*.settings
+*.rptproj.rsuser
+
+# Microsoft Fakes
+FakesAssemblies/
+
+# GhostDoc plugin setting file
+*.GhostDoc.xml
+
+# Node.js Tools for Visual Studio
+.ntvs_analysis.dat
+node_modules/
+
+# Visual Studio 6 build log
+*.plg
+
+# Visual Studio 6 workspace options file
+*.opt
+
+# Visual Studio 6 auto-generated workspace file (contains which files were 
open etc.)
+*.vbw
+
+# Visual Studio LightSwitch build output
+**/*.HTMLClient/GeneratedArtifacts
+**/*.DesktopClient/GeneratedArtifacts
+**/*.DesktopClient/ModelManifest.xml
+**/*.Server/GeneratedArtifacts
+**/*.Server/ModelManifest.xml
+_Pvt_Extensions
+
+# Paket dependency manager
+.paket/paket.exe
+paket-files/
+
+# FAKE - F# Make
+.fake/
+
+# JetBrains Rider
+.idea/
+*.sln.iml
+
+# CodeRush
+.cr/
+
+# Python Tools for Visual Studio (PTVS)
+__pycache__/
+*.pyc
+
+# Cake - Uncomment if you are using it
+# tools/**
+# !tools/packages.config
+
+# Tabs Studio
+*.tss
+
+# Telerik's JustMock configuration file
+*.jmconfig
+
+# BizTalk build output
+*.btp.cs
+*.btm.cs
+*.odx.cs
+*.xsd.cs
+
+# OpenCover UI analysis results
+OpenCover/
+
+# Azure Stream Analytics local run output 
+ASALocalRun/
+
+# MSBuild Binary and Structured Log
+*.binlog
+
+# NVidia Nsight GPU debugger configuration file
+*.nvuser
+
+# MFractors (Xamarin productivity tool) working folder 
+.mfractor/
\ No newline at end of file
diff --git a/README.md b/README.md
index 8b13789..968360b 100644
--- a/README.md
+++ b/README.md
@@ -1 +1,47 @@
+# Shenyu .NET client
 
+## Getting Started
+
+### ASP.NET Core project
+
+For ASP.NET Core project, we can refer to the example code at 
`examples/AspNetCoreExample`. What you need to do is quite
+simple and straightforward.
+
+First, add the Shenyu ASP.NET Core dependency into project.
+
+```shell
+dotnet add package <todo>
+```
+
+Then, in `Startup.ConfigureServices` method, add the `ShenyuRegister` service.
+
+```c#
+public void ConfigureServices(IServiceCollection services)
+{
+    ...
+    services.AddShenyuRegister(this.Configuration);
+    ...
+}
+```
+
+Finnaly, set your `Shenyu` configurations in `appsettings.json`.
+
+```json
+{
+    "Shenyu": {
+        "Register": {
+            "ServerList": "http://localhost:9095";,
+            "UserName": "<your_admin_user>",
+            "Password": "<your_admin_password>"
+        },
+        "Client": {
+            "AppName": "dotnet-example",
+            "ContextPath": "/dotnet",
+            "IsFull": false,
+            "ClientType": "http"
+        }
+    }
+}
+```
+
+That's all! After finished above steps, you can just start your project and 
you can visit `shenyu-admin` portal to see the APIs have been registered in 
Shenyu.
diff --git a/ShenyuClient.sln b/ShenyuClient.sln
new file mode 100644
index 0000000..d181c2a
--- /dev/null
+++ b/ShenyuClient.sln
@@ -0,0 +1,86 @@
+
+Microsoft Visual Studio Solution File, Format Version 12.00
+# Visual Studio Version 16
+VisualStudioVersion = 16.0.30114.105
+MinimumVisualStudioVersion = 10.0.40219.1
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "client", "client", 
"{91252D3C-1AEC-4C52-A2C8-091A907CF4E7}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Apache.ShenYu.Client", 
"client\Apache.ShenYu.Client\Apache.ShenYu.Client.csproj", 
"{91D50BB4-2A2A-4958-A254-8E7615516411}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = 
"Apache.ShenYu.Client.Tests", 
"client\Apache.ShenYu.Client.Tests\Apache.ShenYu.Client.Tests.csproj", 
"{B807F1BF-5757-4243-A962-9A47D5EB55A6}"
+EndProject
+Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "examples", "examples", 
"{B0929019-98BA-4CBB-AA73-DD3E7AAD7CB9}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "AspNetCoreExample", 
"examples\AspNetCoreExample\AspNetCoreExample.csproj", 
"{863FF829-2DCB-4366-A1C2-167B6E5C8618}"
+EndProject
+Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = 
"Apache.ShenYu.AspNetCore", 
"client\Apache.ShenYu.AspNetCore\Apache.ShenYu.AspNetCore.csproj", 
"{07B172F6-22EE-4D97-A124-B36078266631}"
+EndProject
+Global
+       GlobalSection(SolutionConfigurationPlatforms) = preSolution
+               Debug|Any CPU = Debug|Any CPU
+               Debug|x64 = Debug|x64
+               Debug|x86 = Debug|x86
+               Release|Any CPU = Release|Any CPU
+               Release|x64 = Release|x64
+               Release|x86 = Release|x86
+       EndGlobalSection
+       GlobalSection(SolutionProperties) = preSolution
+               HideSolutionNode = FALSE
+       EndGlobalSection
+       GlobalSection(ProjectConfigurationPlatforms) = postSolution
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Debug|Any CPU.ActiveCfg 
= Debug|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Debug|Any CPU.Build.0 = 
Debug|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Debug|x64.ActiveCfg = 
Debug|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Debug|x64.Build.0 = 
Debug|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Debug|x86.ActiveCfg = 
Debug|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Debug|x86.Build.0 = 
Debug|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Release|Any 
CPU.ActiveCfg = Release|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Release|Any CPU.Build.0 
= Release|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Release|x64.ActiveCfg = 
Release|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Release|x64.Build.0 = 
Release|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Release|x86.ActiveCfg = 
Release|Any CPU
+               {91D50BB4-2A2A-4958-A254-8E7615516411}.Release|x86.Build.0 = 
Release|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|Any CPU.ActiveCfg 
= Debug|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|Any CPU.Build.0 = 
Debug|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|x64.ActiveCfg = 
Debug|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|x64.Build.0 = 
Debug|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|x86.ActiveCfg = 
Debug|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Debug|x86.Build.0 = 
Debug|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|Any 
CPU.ActiveCfg = Release|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|Any CPU.Build.0 
= Release|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|x64.ActiveCfg = 
Release|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|x64.Build.0 = 
Release|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|x86.ActiveCfg = 
Release|Any CPU
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6}.Release|x86.Build.0 = 
Release|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Debug|Any CPU.ActiveCfg 
= Debug|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Debug|Any CPU.Build.0 = 
Debug|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Debug|x64.ActiveCfg = 
Debug|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Debug|x64.Build.0 = 
Debug|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Debug|x86.ActiveCfg = 
Debug|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Debug|x86.Build.0 = 
Debug|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Release|Any 
CPU.ActiveCfg = Release|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Release|Any CPU.Build.0 
= Release|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Release|x64.ActiveCfg = 
Release|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Release|x64.Build.0 = 
Release|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Release|x86.ActiveCfg = 
Release|Any CPU
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618}.Release|x86.Build.0 = 
Release|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Debug|Any CPU.ActiveCfg 
= Debug|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Debug|Any CPU.Build.0 = 
Debug|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Debug|x64.ActiveCfg = 
Debug|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Debug|x64.Build.0 = 
Debug|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Debug|x86.ActiveCfg = 
Debug|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Debug|x86.Build.0 = 
Debug|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Release|Any 
CPU.ActiveCfg = Release|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Release|Any CPU.Build.0 
= Release|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Release|x64.ActiveCfg = 
Release|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Release|x64.Build.0 = 
Release|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Release|x86.ActiveCfg = 
Release|Any CPU
+               {07B172F6-22EE-4D97-A124-B36078266631}.Release|x86.Build.0 = 
Release|Any CPU
+       EndGlobalSection
+       GlobalSection(NestedProjects) = preSolution
+               {91D50BB4-2A2A-4958-A254-8E7615516411} = 
{91252D3C-1AEC-4C52-A2C8-091A907CF4E7}
+               {B807F1BF-5757-4243-A962-9A47D5EB55A6} = 
{91252D3C-1AEC-4C52-A2C8-091A907CF4E7}
+               {863FF829-2DCB-4366-A1C2-167B6E5C8618} = 
{B0929019-98BA-4CBB-AA73-DD3E7AAD7CB9}
+               {07B172F6-22EE-4D97-A124-B36078266631} = 
{91252D3C-1AEC-4C52-A2C8-091A907CF4E7}
+       EndGlobalSection
+EndGlobal
diff --git a/client/Apache.ShenYu.AspNetCore/Apache.ShenYu.AspNetCore.csproj 
b/client/Apache.ShenYu.AspNetCore/Apache.ShenYu.AspNetCore.csproj
new file mode 100644
index 0000000..279c8f1
--- /dev/null
+++ b/client/Apache.ShenYu.AspNetCore/Apache.ShenYu.AspNetCore.csproj
@@ -0,0 +1,34 @@
+<!--
+ - Licensed under the Apache License, Version 2.0 (the "License");
+ - you may not use this file except in compliance with the License.
+ - You may obtain a copy of the License at
+ -
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing, software
+ - distributed under the License is distributed on an "AS IS" BASIS,
+ - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ - See the License for the specific language governing permissions and
+ - limitations under the License.
+-->
+
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
+    <RootNamespace>Apache.Shenyu.AspNetCore</RootNamespace>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <ProjectReference 
Include="..\Apache.ShenYu.Client\Apache.ShenYu.Client.csproj" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.AspNetCore.Http.Abstractions" 
Version="2.2.0" />
+    <PackageReference Include="Microsoft.AspNetCore.Mvc.Core" Version="2.2.0" 
/>
+    <PackageReference Include="Microsoft.Extensions.Hosting.Abstractions" 
Version="6.0.0" />
+    <PackageReference Include="Microsoft.AspNetCore" Version="2.2.0" />
+    <PackageReference Include="Microsoft.Extensions.Configuration" 
Version="2.2.0" />
+  </ItemGroup>
+
+</Project>
diff --git a/client/Apache.ShenYu.AspNetCore/README.md 
b/client/Apache.ShenYu.AspNetCore/README.md
new file mode 100644
index 0000000..f6b9785
--- /dev/null
+++ b/client/Apache.ShenYu.AspNetCore/README.md
@@ -0,0 +1,7 @@
+# Shenyu ASP.NET Core
+
+## TODO
+
+- [x] parse '[controller]' in '[Route]' attribute.
+- [x] fix URL path.
+- [x] support https.
diff --git a/client/Apache.ShenYu.AspNetCore/Services/ShenyuStartupService.cs 
b/client/Apache.ShenYu.AspNetCore/Services/ShenyuStartupService.cs
new file mode 100644
index 0000000..848614d
--- /dev/null
+++ b/client/Apache.ShenYu.AspNetCore/Services/ShenyuStartupService.cs
@@ -0,0 +1,193 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Reflection;
+using System.Threading;
+using System.Threading.Tasks;
+using Apache.ShenYu.Client.Attibutes;
+using Apache.ShenYu.Client.Models.DTO;
+using Apache.ShenYu.Client.Options;
+using Apache.ShenYu.Client.Registers;
+using Microsoft.AspNetCore.Hosting.Server;
+using Microsoft.AspNetCore.Hosting.Server.Features;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.AspNetCore.Mvc.ApplicationParts;
+using Microsoft.AspNetCore.Mvc.Controllers;
+using Microsoft.AspNetCore.Mvc.Routing;
+using Microsoft.Extensions.Hosting;
+using Microsoft.Extensions.Logging;
+using Microsoft.Extensions.Options;
+
+namespace Apache.ShenYu.AspNetCore.Services
+{
+    public class ShenyuStartupService : IHostedService
+    {
+        private readonly ILogger<ShenyuStartupService> _logger;
+        private readonly IServer _server;
+        private readonly IHostApplicationLifetime _hostApplicationLifetime;
+        private readonly IShenyuRegister _shenyuRegister;
+        private readonly IOptions<ShenyuOptions> _shenyuOptions;
+        private readonly ApplicationPartManager _partManager;
+
+        public ShenyuStartupService(
+            ILogger<ShenyuStartupService> logger,
+            IServer server,
+            IHostApplicationLifetime hostApplicationLifetime,
+            IShenyuRegister shenyuRegister,
+            IOptions<ShenyuOptions> shenyuOptions,
+            ApplicationPartManager partManager
+        )
+        {
+            this._logger = logger;
+            this._server = server;
+            this._hostApplicationLifetime = hostApplicationLifetime;
+            this._shenyuRegister = shenyuRegister;
+            this._shenyuOptions = shenyuOptions;
+            this._partManager = partManager;
+        }
+
+        public Task StartAsync(CancellationToken cancellationToken)
+        {
+            this._hostApplicationLifetime.ApplicationStarted.Register(async () 
=>
+            {
+                await this._shenyuRegister.Init(this._shenyuOptions.Value);
+
+                var addresses = this.GetAddresses();
+                var rpcTypes = this._shenyuOptions.Value.Client.ClientType
+                    .Split(',')
+                    .Select(type => type.Trim())
+                    .ToList();
+                foreach (var address in addresses)
+                {
+                    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("/", basePath, path);
+
+                                await 
this._shenyuRegister.PersistInterface(this.BuildMetadataDto(wholePath, 
address));
+                            }
+                        }
+                    }
+
+                    await 
this._shenyuRegister.PersistURI(this.BuildUriRegisterDto(address));
+                }
+            });
+
+            return Task.CompletedTask;
+        }
+
+        private ICollection<string> GetAddresses()
+        {
+            return 
this._server.Features.Get<IServerAddressesFeature>().Addresses;
+        }
+
+        public Task StopAsync(CancellationToken cancellationToken) => 
Task.CompletedTask;
+
+        private MetaDataRegisterDTO BuildMetadataDto(string path, string 
address)
+        {
+            var uri = new Uri(address);
+            return new MetaDataRegisterDTO
+            {
+                appName = this._shenyuOptions.Value.Client.AppName,
+                contextPath = this._shenyuOptions.Value.Client.ContextPath,
+                path = this._shenyuOptions.Value.Client.ContextPath + 
(string.IsNullOrEmpty(path) ? "/**" : path),
+                rpcType = uri.Scheme,
+                ruleName = this._shenyuOptions.Value.Client.ContextPath + 
(string.IsNullOrEmpty(path) ? "/**" : path),
+                enabled = true,
+            };
+        }
+
+        private URIRegisterDTO BuildUriRegisterDto(string address)
+        {
+            var uri = new Uri(address);
+            return new URIRegisterDTO
+            {
+                protocol = $"{uri.Scheme}://",
+                appName = this._shenyuOptions.Value.Client.AppName,
+                contextPath = this._shenyuOptions.Value.Client.ContextPath,
+                rpcType = this._shenyuOptions.Value.Client.ClientType,
+                host = uri.Host,
+                port = uri.Port,
+            };
+        }
+
+        private string GetPath(ShenyuClientAttribute shenyuClientAttribute, 
IRouteTemplateProvider routeAttribute,
+            string controllerName = null)
+        {
+            string routePath = routeAttribute.Template == null ? "" : 
routeAttribute.Template;
+            if (routePath.Equals("[controller]") && controllerName != null)
+            {
+                routePath = controllerName
+                    .Substring(0, controllerName.IndexOf("Controller", 
StringComparison.Ordinal))
+                    .ToLower();
+            }
+
+            return shenyuClientAttribute != null ? shenyuClientAttribute.Path 
: routePath;
+        }
+    }
+}
diff --git 
a/client/Apache.ShenYu.AspNetCore/Utils/ShenyuCollectionExtensions.cs 
b/client/Apache.ShenYu.AspNetCore/Utils/ShenyuCollectionExtensions.cs
new file mode 100644
index 0000000..2dbff1f
--- /dev/null
+++ b/client/Apache.ShenYu.AspNetCore/Utils/ShenyuCollectionExtensions.cs
@@ -0,0 +1,48 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using Apache.ShenYu.AspNetCore.Services;
+using Apache.ShenYu.Client.Options;
+using Apache.ShenYu.Client.Registers;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+
+namespace Apache.ShenYu.AspNetCore.Utils
+{
+    public static class ShenyuCollectionExtensions
+    {
+        /// <summary>
+        /// Add Shenyu register
+        ///
+        /// </summary>
+        /// <param name="services"></param>
+        /// <param name="configuration"></param>
+        /// <exception cref="ArgumentNullException"></exception>
+        public static void AddShenyuRegister(this IServiceCollection services, 
IConfiguration configuration)
+        {
+            if (services == null)
+            {
+                throw new ArgumentNullException(nameof(services));
+            }
+
+            
services.Configure<ShenyuOptions>(configuration.GetSection(ShenyuOptions.Shenyu));
+            services.AddHostedService<ShenyuStartupService>();
+            services.AddSingleton<IShenyuRegister, ShenyuHttpRegister>();
+        }
+    }
+}
diff --git 
a/client/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj 
b/client/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
new file mode 100644
index 0000000..0d226e0
--- /dev/null
+++ b/client/Apache.ShenYu.Client.Tests/Apache.ShenYu.Client.Tests.csproj
@@ -0,0 +1,34 @@
+<!--
+ - Licensed under the Apache License, Version 2.0 (the "License");
+ - you may not use this file except in compliance with the License.
+ - You may obtain a copy of the License at
+ -
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing, software
+ - distributed under the License is distributed on an "AS IS" BASIS,
+ - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ - See the License for the specific language governing permissions and
+ - limitations under the License.
+-->
+
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
+    <IsPackable>false</IsPackable>
+    <RootNamespace>ShenyuClientTest</RootNamespace>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.7.1" />
+    <PackageReference Include="MSTest.TestAdapter" Version="2.1.1" />
+    <PackageReference Include="MSTest.TestFramework" Version="2.1.1" />
+    <PackageReference Include="coverlet.collector" Version="1.3.0" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference 
Include="..\Apache.ShenYu.Client\Apache.ShenYu.Client.csproj" />
+  </ItemGroup>
+
+</Project>
diff --git a/client/Apache.ShenYu.Client/Apache.ShenYu.Client.csproj 
b/client/Apache.ShenYu.Client/Apache.ShenYu.Client.csproj
new file mode 100644
index 0000000..1edc218
--- /dev/null
+++ b/client/Apache.ShenYu.Client/Apache.ShenYu.Client.csproj
@@ -0,0 +1,36 @@
+<!--
+ - Licensed under the Apache License, Version 2.0 (the "License");
+ - you may not use this file except in compliance with the License.
+ - You may obtain a copy of the License at
+ - 
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing, software
+ - distributed under the License is distributed on an "AS IS" BASIS,
+ - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ - See the License for the specific language governing permissions and
+ - limitations under the License.
+-->
+
+<Project Sdk="Microsoft.NET.Sdk">
+
+  <PropertyGroup>
+    <TargetFrameworks>netstandard2.0;net461</TargetFrameworks>
+    <RootNamespace>Apache.Shenyu.Client</RootNamespace>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <None Remove="Registers\" />
+    <None Remove="Models\" />
+    <None Remove="Models\DTO\" />
+  </ItemGroup>
+  <ItemGroup>
+    <Folder Include="Registers\" />
+    <Folder Include="Models\" />
+    <Folder Include="Models\DTO\" />
+  </ItemGroup>
+  <ItemGroup>
+    <PackageReference Include="Microsoft.Extensions.Logging.Abstractions" 
Version="2.2.0" />
+    <PackageReference Include="Newtonsoft.Json" Version="9.0.1" />
+  </ItemGroup>
+</Project>
diff --git a/client/Apache.ShenYu.Client/Attibutes/ShenyuClientAttribute.cs 
b/client/Apache.ShenYu.Client/Attibutes/ShenyuClientAttribute.cs
new file mode 100644
index 0000000..3d04982
--- /dev/null
+++ b/client/Apache.ShenYu.Client/Attibutes/ShenyuClientAttribute.cs
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace Apache.ShenYu.Client.Attibutes
+{
+    [AttributeUsage(AttributeTargets.Class | AttributeTargets.Method)]
+    public class ShenyuClientAttribute : Attribute
+    {
+        public string Path { get; set; }
+        public string RuleName { get; set; }
+        public string Desc { get; set; }
+        public bool Enabled { get; set; }
+        public bool RegisterMetaData { get; set; }
+
+        public ShenyuClientAttribute(string path)
+        {
+            this.Path = path;
+        }
+    }
+}
+
diff --git a/client/Apache.ShenYu.Client/Models/DTO/MetaDataRegisterDTO.cs 
b/client/Apache.ShenYu.Client/Models/DTO/MetaDataRegisterDTO.cs
new file mode 100644
index 0000000..18312fe
--- /dev/null
+++ b/client/Apache.ShenYu.Client/Models/DTO/MetaDataRegisterDTO.cs
@@ -0,0 +1,57 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+
+namespace Apache.ShenYu.Client.Models.DTO
+{
+    public class MetaDataRegisterDTO
+    {
+        public String appName { get; set; }
+
+        public String contextPath { get; set; }
+
+        public String path { get; set; }
+
+        public String pathDesc { get; set; }
+
+        public String rpcType { get; set; }
+
+        public String serviceName { get; set; }
+
+        public String methodName { get; set; }
+
+        public String ruleName { get; set; }
+
+        public String parameterTypes { get; set; }
+
+        public String rpcExt { get; set; }
+
+        public bool enabled { get; set; }
+
+        public String host { get; set; }
+
+        public int port { get; set; }
+
+        public List<String> pluginNames { get; set; }
+
+        public bool registerMetaData { get; set; }
+
+        public long timeMillis { get; set; }
+    }
+}
diff --git a/client/Apache.ShenYu.Client/Models/DTO/URIRegisterDTO.cs 
b/client/Apache.ShenYu.Client/Models/DTO/URIRegisterDTO.cs
new file mode 100644
index 0000000..bcd2f9a
--- /dev/null
+++ b/client/Apache.ShenYu.Client/Models/DTO/URIRegisterDTO.cs
@@ -0,0 +1,29 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.ShenYu.Client.Models.DTO
+{
+    public class URIRegisterDTO
+    {
+        public string protocol { get; set; }
+        public string appName { get; set; }
+        public string contextPath { get; set; }
+        public string rpcType { get; set; }
+        public string host { get; set; }
+        public int port { get; set; }
+    }
+}
diff --git a/client/Apache.ShenYu.Client/Options/ShenyuOptions.cs 
b/client/Apache.ShenYu.Client/Options/ShenyuOptions.cs
new file mode 100644
index 0000000..aa9504c
--- /dev/null
+++ b/client/Apache.ShenYu.Client/Options/ShenyuOptions.cs
@@ -0,0 +1,43 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.ShenYu.Client.Options
+{
+    public class ShenyuOptions
+    {
+        public const string Shenyu = "Shenyu";
+
+        public RegisterOptions Register { get; set; }
+        public ClientOptions Client { get; set; }
+
+        public class RegisterOptions
+        {
+            public string RegisterType { get; set; } = "http";
+            public string ServerList { get; set; }
+            public string UserName { get; set; }
+            public string Password { get; set; }
+        }
+
+        public class ClientOptions
+        {
+            public string AppName { get; set; }
+            public string ContextPath { get; set; }
+            public bool IsFull { get; set; } = false;
+            public string ClientType { get; set; }
+        }
+    }
+}
diff --git a/client/Apache.ShenYu.Client/Registers/IShenyuRegister.cs 
b/client/Apache.ShenYu.Client/Registers/IShenyuRegister.cs
new file mode 100644
index 0000000..ddd01af
--- /dev/null
+++ b/client/Apache.ShenYu.Client/Registers/IShenyuRegister.cs
@@ -0,0 +1,49 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System.Threading.Tasks;
+using Apache.ShenYu.Client.Models.DTO;
+using Apache.ShenYu.Client.Options;
+
+namespace Apache.ShenYu.Client.Registers
+{
+    public interface IShenyuRegister
+    {
+        /// <summary>
+        ///
+        /// </summary>
+        /// <param name="shenyuOptions"></param>
+        Task Init(ShenyuOptions shenyuOptions);
+
+        /// <summary>
+        ///
+        /// </summary>
+        /// <param name="metadata"></param>
+        Task PersistInterface(MetaDataRegisterDTO metadata);
+
+        /// <summary>
+        /// persist URI.
+        /// </summary>
+        /// <param name="registerDTO"></param>
+        Task PersistURI(URIRegisterDTO registerDTO);
+
+        /// <summary>
+        /// Close.
+        /// </summary>
+        void Close();
+    }
+}
diff --git a/client/Apache.ShenYu.Client/Registers/ShenyuHttpRegister.cs 
b/client/Apache.ShenYu.Client/Registers/ShenyuHttpRegister.cs
new file mode 100644
index 0000000..428e1ce
--- /dev/null
+++ b/client/Apache.ShenYu.Client/Registers/ShenyuHttpRegister.cs
@@ -0,0 +1,137 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Net.Http;
+using System.Text;
+using System.Threading.Tasks;
+using Apache.ShenYu.Client.Models.DTO;
+using Apache.ShenYu.Client.Options;
+using Apache.ShenYu.Client.Utils;
+using Microsoft.Extensions.Logging;
+using Newtonsoft.Json;
+using Newtonsoft.Json.Linq;
+
+namespace Apache.ShenYu.Client.Registers
+{
+    public class ShenyuHttpRegister : IShenyuRegister
+    {
+        public string UserName { get; set; }
+        public string Password { get; set; }
+        public List<string> ServerList { get; set; }
+
+        private Dictionary<string, string> AccessTokens { get; set; }
+
+        private HttpClient _client;
+        private URIRegisterDTO _uriRegisterDto;
+        private ShenyuOptions _shenyuOptions;
+        private readonly ILogger<ShenyuHttpRegister> _logger;
+
+        public ShenyuHttpRegister(ILogger<ShenyuHttpRegister> logger)
+        {
+            this._logger = logger;
+        }
+
+        public async Task Init(ShenyuOptions shenyuOptions)
+        {
+            this._shenyuOptions = shenyuOptions;
+            this.UserName = this._shenyuOptions.Register.UserName;
+            this.Password = this._shenyuOptions.Register.Password;
+            this.ServerList = 
this._shenyuOptions.Register.ServerList?.Split(',').ToList();
+            this.AccessTokens = new Dictionary<string, string>();
+            this._client = new HttpClient();
+            await this.SetAccessTokens();
+        }
+
+        public async Task PersistInterface(MetaDataRegisterDTO metadata)
+        {
+            await this.DoRegister(metadata, Constants.MetaPath);
+        }
+
+        public async Task PersistURI(URIRegisterDTO registerDTO)
+        {
+            await this.DoRegister(registerDTO, Constants.URIPath);
+            this._uriRegisterDto = registerDTO;
+        }
+
+        public void Close()
+        {
+            throw new NotImplementedException();
+        }
+
+        /// <summary>
+        /// Get access token
+        ///
+        /// </summary>
+        /// <returns></returns>
+        private async Task SetAccessTokens()
+        {
+            List<Task> tasks = new List<Task>();
+            foreach (var server in this.ServerList)
+            {
+                tasks.Add(this.SetAccessToken(server));
+            }
+
+            await Task.WhenAll(tasks);
+            Console.WriteLine("finished access token.");
+        }
+
+        private async Task SetAccessToken(string server)
+        {
+            var builder = new UriBuilder(server) { Path = Constants.LoginPath, 
Query = $"userName={this.UserName}&password={this.Password}" };
+            var resp = await this._client.GetStringAsync(builder.ToString());
+            var jObject = JObject.Parse(resp);
+            var token = jObject["data"]?["token"].ToString();
+
+            this.AccessTokens.Add(server, token);
+        }
+
+        private async Task DoRegister<T>(T t, string path)
+        {
+            foreach (var server in this.ServerList)
+            {
+                string accessToken;
+                if (!this.AccessTokens.TryGetValue(server, out accessToken))
+                {
+                    await this.SetAccessToken(server);
+                    if (!this.AccessTokens.TryGetValue(server, out 
accessToken))
+                    {
+                        throw new NullReferenceException("access token is 
null.");
+                    }
+                }
+
+                var requestMessage = new HttpRequestMessage(HttpMethod.Post, 
new Uri($"{server}{path}"));
+                requestMessage.Headers.Add(Constants.XAccessToken, 
accessToken);
+                requestMessage.Content = new StringContent(
+                    JsonConvert.SerializeObject(t),
+                    Encoding.UTF8, "application/json");
+
+                var resp = await this._client.SendAsync(requestMessage);
+                if (resp.IsSuccessStatusCode)
+                {
+                    this._logger.LogInformation("success");
+                }
+                else
+                {
+                    this._logger.LogInformation("failed");
+                }
+            }
+        }
+    }
+}
diff --git a/client/Apache.ShenYu.Client/Utils/Constants.cs 
b/client/Apache.ShenYu.Client/Utils/Constants.cs
new file mode 100644
index 0000000..f8e5885
--- /dev/null
+++ b/client/Apache.ShenYu.Client/Utils/Constants.cs
@@ -0,0 +1,27 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+namespace Apache.ShenYu.Client.Utils
+{
+    public class Constants
+    {
+        public const string LoginPath = "/platform/login";
+        public const string XAccessToken = "X-Access-Token";
+        public const string URIPath = "/shenyu-client/register-uri";
+        public const string MetaPath = "/shenyu-client/register-metadata";
+    }
+}
diff --git a/examples/AspNetCoreExample/AspNetCoreExample.csproj 
b/examples/AspNetCoreExample/AspNetCoreExample.csproj
new file mode 100644
index 0000000..fd49009
--- /dev/null
+++ b/examples/AspNetCoreExample/AspNetCoreExample.csproj
@@ -0,0 +1,29 @@
+<!--
+ - Licensed under the Apache License, Version 2.0 (the "License");
+ - you may not use this file except in compliance with the License.
+ - You may obtain a copy of the License at
+ -
+ -   http://www.apache.org/licenses/LICENSE-2.0
+ -
+ - Unless required by applicable law or agreed to in writing, software
+ - distributed under the License is distributed on an "AS IS" BASIS,
+ - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ - See the License for the specific language governing permissions and
+ - limitations under the License.
+-->
+
+<Project Sdk="Microsoft.NET.Sdk.Web">
+
+  <PropertyGroup>
+    <TargetFramework>netcoreapp3.1</TargetFramework>
+  </PropertyGroup>
+
+  <ItemGroup>
+    <PackageReference Include="Swashbuckle.AspNetCore" Version="5.6.3" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <ProjectReference 
Include="..\..\client\Apache.ShenYu.AspNetCore\Apache.ShenYu.AspNetCore.csproj" 
/>
+  </ItemGroup>
+
+</Project>
diff --git a/examples/AspNetCoreExample/Controllers/TemplateController.cs 
b/examples/AspNetCoreExample/Controllers/TemplateController.cs
new file mode 100644
index 0000000..7007b8b
--- /dev/null
+++ b/examples/AspNetCoreExample/Controllers/TemplateController.cs
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.ShenYu.Client.Attibutes;
+using Microsoft.AspNetCore.Hosting.Server;
+using Microsoft.AspNetCore.Hosting.Server.Features;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace AspNetCoreExample.Controllers
+{
+    [ApiController]
+    [Route("[controller]")]
+    public class TemplateController
+    {
+        private static readonly string[] Summaries = new[]
+        {
+            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", 
"Hot", "Sweltering", "Scorching"
+        };
+
+        private readonly ILogger<WeatherForecastController> _logger;
+
+        public TemplateController(ILogger<WeatherForecastController> logger, 
IServer server)
+        {
+            this._logger = logger;
+            var addresses = 
server.Features.Get<IServerAddressesFeature>().Addresses;
+        }
+
+        [HttpGet("hello")]
+        [ShenyuClient("hello")]
+        public IEnumerable<WeatherForecast> GetTest()
+        {
+            var rng = new Random();
+            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+            {
+                Date = DateTime.Now.AddDays(index),
+                TemperatureC = rng.Next(-20, 55),
+                Summary = Summaries[rng.Next(Summaries.Length)]
+            })
+            .ToArray();
+        }
+
+        [HttpPost]
+        public IEnumerable<WeatherForecast> PostTest()
+        {
+            var rng = new Random();
+            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+                {
+                    Date = DateTime.Now.AddDays(index),
+                    TemperatureC = rng.Next(-20, 55),
+                    Summary = Summaries[rng.Next(Summaries.Length)]
+                })
+                .ToArray();
+        }
+    }
+}
diff --git a/examples/AspNetCoreExample/Controllers/TestController.cs 
b/examples/AspNetCoreExample/Controllers/TestController.cs
new file mode 100644
index 0000000..9687cf3
--- /dev/null
+++ b/examples/AspNetCoreExample/Controllers/TestController.cs
@@ -0,0 +1,74 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.ShenYu.Client.Attibutes;
+using Microsoft.AspNetCore.Hosting.Server;
+using Microsoft.AspNetCore.Hosting.Server.Features;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace AspNetCoreExample.Controllers
+{
+    // [ApiController]
+    [Route("[controller]")]
+    [ShenyuClient("/test/**")]
+    public class TestController
+    {
+        private static readonly string[] Summaries = new[]
+        {
+            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", 
"Hot", "Sweltering", "Scorching"
+        };
+
+        private readonly ILogger<WeatherForecastController> _logger;
+
+        public TestController(ILogger<WeatherForecastController> logger, 
IServer server)
+        {
+            this._logger = logger;
+            var addresses = 
server.Features.Get<IServerAddressesFeature>().Addresses;
+        }
+
+        [HttpGet("hello")]
+        [ShenyuClient("hello")]
+        public IEnumerable<WeatherForecast> GetTest()
+        {
+            var rng = new Random();
+            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+            {
+                Date = DateTime.Now.AddDays(index),
+                TemperatureC = rng.Next(-20, 55),
+                Summary = Summaries[rng.Next(Summaries.Length)]
+            })
+            .ToArray();
+        }
+
+        [HttpPost]
+        public IEnumerable<WeatherForecast> PostTest()
+        {
+            var rng = new Random();
+            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+                {
+                    Date = DateTime.Now.AddDays(index),
+                    TemperatureC = rng.Next(-20, 55),
+                    Summary = Summaries[rng.Next(Summaries.Length)]
+                })
+                .ToArray();
+        }
+    }
+}
diff --git 
a/examples/AspNetCoreExample/Controllers/WeatherForecastController.cs 
b/examples/AspNetCoreExample/Controllers/WeatherForecastController.cs
new file mode 100644
index 0000000..b4a1222
--- /dev/null
+++ b/examples/AspNetCoreExample/Controllers/WeatherForecastController.cs
@@ -0,0 +1,73 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using Apache.ShenYu.Client.Attibutes;
+using Microsoft.AspNetCore.Hosting.Server;
+using Microsoft.AspNetCore.Hosting.Server.Features;
+using Microsoft.AspNetCore.Mvc;
+using Microsoft.Extensions.Logging;
+
+namespace AspNetCoreExample.Controllers
+{
+    [ApiController]
+    [Route("/weather")]
+    [ShenyuClient("/weather")]
+    public class WeatherForecastController : ControllerBase
+    {
+        private static readonly string[] Summaries = new[]
+        {
+            "Freezing", "Bracing", "Chilly", "Cool", "Mild", "Warm", "Balmy", 
"Hot", "Sweltering", "Scorching"
+        };
+
+        private readonly ILogger<WeatherForecastController> _logger;
+
+        public WeatherForecastController(ILogger<WeatherForecastController> 
logger, IServer server)
+        {
+            this._logger = logger;
+            var addresses = 
server.Features.Get<IServerAddressesFeature>().Addresses;
+        }
+
+        [HttpGet("hello")]
+        [ShenyuClient("hello")]
+        public IEnumerable<WeatherForecast> Get()
+        {
+            var rng = new Random();
+            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+            {
+                Date = DateTime.Now.AddDays(index),
+                TemperatureC = rng.Next(-20, 55),
+                Summary = Summaries[rng.Next(Summaries.Length)]
+            })
+            .ToArray();
+        }
+
+        [HttpPost]
+        public IEnumerable<WeatherForecast> Post()
+        {
+            var rng = new Random();
+            return Enumerable.Range(1, 5).Select(index => new WeatherForecast
+                {
+                    Date = DateTime.Now.AddDays(index),
+                    TemperatureC = rng.Next(-20, 55),
+                    Summary = Summaries[rng.Next(Summaries.Length)]
+                })
+                .ToArray();
+        }
+    }
+}
diff --git a/examples/AspNetCoreExample/Program.cs 
b/examples/AspNetCoreExample/Program.cs
new file mode 100644
index 0000000..acb5204
--- /dev/null
+++ b/examples/AspNetCoreExample/Program.cs
@@ -0,0 +1,37 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Hosting;
+
+namespace AspNetCoreExample
+{
+    public class Program
+    {
+        public static void Main(string[] args)
+        {
+            CreateHostBuilder(args).Build().Run();
+        }
+
+        public static IHostBuilder CreateHostBuilder(string[] args) =>
+            Host.CreateDefaultBuilder(args)
+                .ConfigureWebHostDefaults(webBuilder =>
+                {
+                    webBuilder.UseStartup<Startup>();
+                });
+    }
+}
diff --git a/examples/AspNetCoreExample/Properties/launchSettings.json 
b/examples/AspNetCoreExample/Properties/launchSettings.json
new file mode 100644
index 0000000..2ee9ca8
--- /dev/null
+++ b/examples/AspNetCoreExample/Properties/launchSettings.json
@@ -0,0 +1,31 @@
+{
+  "$schema": "http://json.schemastore.org/launchsettings.json";,
+  "iisSettings": {
+    "windowsAuthentication": false,
+    "anonymousAuthentication": true,
+    "iisExpress": {
+      "applicationUrl": "http://localhost:1881";,
+      "sslPort": 44366
+    }
+  },
+  "profiles": {
+    "IIS Express": {
+      "commandName": "IISExpress",
+      "launchBrowser": true,
+      "launchUrl": "swagger",
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    },
+    "ShenyuExample": {
+      "commandName": "Project",
+      "dotnetRunMessages": "true",
+      "launchBrowser": true,
+      "launchUrl": "swagger",
+      "applicationUrl": "https://localhost:5001;http://localhost:5000";,
+      "environmentVariables": {
+        "ASPNETCORE_ENVIRONMENT": "Development"
+      }
+    }
+  }
+}
diff --git a/examples/AspNetCoreExample/Startup.cs 
b/examples/AspNetCoreExample/Startup.cs
new file mode 100644
index 0000000..97a8a5d
--- /dev/null
+++ b/examples/AspNetCoreExample/Startup.cs
@@ -0,0 +1,67 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using Apache.ShenYu.AspNetCore.Utils;
+using Microsoft.AspNetCore.Builder;
+using Microsoft.AspNetCore.Hosting;
+using Microsoft.Extensions.Configuration;
+using Microsoft.Extensions.DependencyInjection;
+using Microsoft.Extensions.Hosting;
+using Microsoft.OpenApi.Models;
+
+namespace AspNetCoreExample
+{
+    public class Startup
+    {
+        public Startup(IConfiguration configuration)
+        {
+            this.Configuration = configuration;
+        }
+
+        public IConfiguration Configuration { get; }
+
+        // This method gets called by the runtime. Use this method to add 
services to the container.
+        public void ConfigureServices(IServiceCollection services)
+        {
+            services.AddControllers();
+            services.AddSwaggerGen(c =>
+            {
+                c.SwaggerDoc("v1", new OpenApiInfo { Title = 
"AspNetCoreExample", Version = "v1" });
+            });
+            services.AddShenyuRegister(this.Configuration);
+        }
+
+        // This method gets called by the runtime. Use this method to 
configure the HTTP request pipeline.
+        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
+        {
+            if (env.IsDevelopment())
+            {
+                app.UseDeveloperExceptionPage();
+                app.UseSwagger();
+                app.UseSwaggerUI(c => 
c.SwaggerEndpoint("/swagger/v1/swagger.json", "AspNetCoreExample v1"));
+            }
+
+            // app.UseHttpsRedirection();
+            app.UseRouting();
+            app.UseAuthorization();
+            app.UseEndpoints(endpoints =>
+            {
+                endpoints.MapControllers();
+            });
+        }
+    }
+}
diff --git a/examples/AspNetCoreExample/WeatherForecast.cs 
b/examples/AspNetCoreExample/WeatherForecast.cs
new file mode 100644
index 0000000..9b0b35b
--- /dev/null
+++ b/examples/AspNetCoreExample/WeatherForecast.cs
@@ -0,0 +1,32 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License.  You may obtain a copy of the License at
+ *
+ *     http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+using System;
+
+namespace AspNetCoreExample
+{
+    public class WeatherForecast
+    {
+        public DateTime Date { get; set; }
+
+        public int TemperatureC { get; set; }
+
+        public int TemperatureF => 32 + (int)(this.TemperatureC / 0.5556);
+
+        public string Summary { get; set; }
+    }
+}
diff --git a/examples/AspNetCoreExample/appsettings.Development.json 
b/examples/AspNetCoreExample/appsettings.Development.json
new file mode 100644
index 0000000..826b17e
--- /dev/null
+++ b/examples/AspNetCoreExample/appsettings.Development.json
@@ -0,0 +1,22 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft": "Warning",
+      "Microsoft.Hosting.Lifetime": "Information"
+    }
+  },
+  "Shenyu": {
+    "Register": {
+      "ServerList": "http://localhost:9095";,
+      "UserName": "admin",
+      "Password": "123456"
+    },
+    "Client": {
+      "AppName": "dotnet-example",
+      "ContextPath": "/dotnet",
+      "IsFull": false,
+      "ClientType": "http"
+    }
+  }
+}
diff --git a/examples/AspNetCoreExample/appsettings.json 
b/examples/AspNetCoreExample/appsettings.json
new file mode 100644
index 0000000..81ff877
--- /dev/null
+++ b/examples/AspNetCoreExample/appsettings.json
@@ -0,0 +1,10 @@
+{
+  "Logging": {
+    "LogLevel": {
+      "Default": "Information",
+      "Microsoft": "Warning",
+      "Microsoft.Hosting.Lifetime": "Information"
+    }
+  },
+  "AllowedHosts": "*"
+}

Reply via email to