
English
API Gateway: Yarp Gateway
For more features, refer to the Yarp Official Documentation
dotnet new install ZhonTai.Template.GatewayThe upgrade template command is the same as the install template command.
dotnet new install ZhonTai.Template.Gateway::10.1.0dotnet new MyGateway -h-p, --port <port> Port settings
Type: int
Default: 16010dotnet new uninstall ZhonTai.Template.Gatewaydotnet new MyGateway -n MyCompanyName.MyGatewaydotnet new MyGateway -n MyCompanyName.MyGateway -p 16010Application configuration file, including route configuration, cluster configuration, certificate configuration, etc.
{
"Logging": {
"LogLevel": {
"Default": "Information",
"Microsoft.AspNetCore": "Warning"
}
},
"AllowedHosts": "*",
"Urls": "http://*:16010",
"ReverseProxy": {
"Routes": {
// Permission management
"admin": {
"ClusterId": "admin",
"Match": {
"Path": "/api/admin/{**catch-all}",
//"Methods": [ "POST", "GET", "DELETE", "PUT" ],
"Hosts": []
}
},
"admin-doc": {
"ClusterId": "admin",
"Match": {
"Path": "/doc/admin/{**catch-all}",
//"Methods": [ "POST", "GET", "DELETE", "PUT" ],
"Hosts": []
}
},
"admin-file": {
"ClusterId": "admin",
"Match": {
"Path": "/upload/{**catch-all}",
"Hosts": []
}
},
// Development management
"dev": {
"ClusterId": "dev",
"Match": {
"Path": "/api/dev/{**catch-all}",
//"Methods": [ "POST", "GET", "DELETE", "PUT" ],
"Hosts": []
}
},
"dev-doc": {
"ClusterId": "dev",
"Match": {
"Path": "/doc/dev/{**catch-all}",
//"Methods": [ "POST", "GET", "DELETE", "PUT" ],
"Hosts": []
}
},
// System management (includes permission management)
"sys": {
"ClusterId": "admin",
"Match": {
"Path": "/api/sys/{**catch-all}",
"Hosts": []
}
},
"sys-doc": {
"ClusterId": "admin",
"Match": {
"Path": "/doc/sys/{**catch-all}",
"Hosts": []
}
},
// Business management
"biz": {
"ClusterId": "biz",
"Match": {
"Path": "/api/biz/{**catch-all}",
//"Methods": [ "POST", "GET", "DELETE", "PUT" ],
"Hosts": []
}
},
"biz-doc": {
"ClusterId": "biz",
"Match": {
"Path": "/doc/biz/{**catch-all}",
//"Methods": [ "POST", "GET", "DELETE", "PUT" ],
"Hosts": []
}
},
// Member management
"mem": {
"ClusterId": "mem",
"Match": {
"Path": "/api/mem/{**catch-all}",
//"Methods": [ "POST", "GET", "DELETE", "PUT" ],
"Hosts": []
}
},
"mem-doc": {
"ClusterId": "mem",
"Match": {
"Path": "/doc/mem/{**catch-all}",
//"Methods": [ "POST", "GET", "DELETE", "PUT" ],
"Hosts": []
}
}
},
"Clusters": {
"admin": {
"Destinations": {
"destination1": {
"Address": "http://localhost:18010"
}
},
"LoadBalancingPolicy": "RoundRobin"
},
"dev": {
"Destinations": {
"destination1": {
"Address": "http://localhost:18020"
}
},
"LoadBalancingPolicy": "RoundRobin"
},
"biz": {
"Destinations": {
"destination1": {
"Address": "http://localhost:19010"
}
},
"LoadBalancingPolicy": "RoundRobin"
},
"mem": {
"Destinations": {
"destination1": {
"Address": "http://localhost:20010"
}
},
"LoadBalancingPolicy": "RoundRobin"
}
}
},
// Gateway configuration
"GatewayConfig": {
// Module list
"ModuleList": [
{
// Document name
"Name": "Admin API Docs",
// Document URL
"Url": "/doc/admin/index.html"
},
{
"Name": "System API Docs",
"Url": "/doc/sys/index.html"
},
{
"Name": "Development API Docs",
"Url": "/doc/dev/index.html"
},
{
"Name": "Business API Docs",
"Url": "/doc/biz/index.html"
},
{
"Name": "Member API Docs",
"Url": "/doc/mem/index.html"
}
],
// Health check
"HealthChecks": {
// Enable
"Enable": true,
// Access path
"Path": "/health"
}
}
}Development startup configuration file, used to configure startup parameters such as environment variables, startup ports, etc.
{
"profiles": {
"MyGateway.Host": {
"commandName": "Project",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
},
"dotnetRunMessages": true,
"applicationUrl": "http://localhost:16010"
},
"IIS Express": {
"commandName": "IISExpress",
"launchBrowser": true,
"environmentVariables": {
"ASPNETCORE_ENVIRONMENT": "Development"
}
}
},
"$schema": "https://json.schemastore.org/launchsettings.json",
"iisSettings": {
"windowsAuthentication": false,
"anonymousAuthentication": true,
"iisExpress": {
"applicationUrl": "http://localhost:16010",
"sslPort": 0
}
}
}