I use YARP as an API gateway and DevExpress for ASP.net Core for UI in my microservice solution.
UI code (port 7004)
gItems.AddSimpleFor(c => c.CustomerID).ColSpan(2)
.Label(l => l.Text(@L["utim_form_CustomerAbbr"]).ShowColon(false))
.Editor(e => e.SelectBox()
.DataSource(d => d.RemoteController()
.LoadUrl("/api/customer-service/customer/basic-list")
.Key("customerID")
)
.DataSourceOptions(c => c.Paginate(true).PageSize(10))
.ID("sb_customer")
.SearchEnabled(true)
.OnValueChanged("onChangedCustomerAbbr")
.ElementAttr("customerName", "customerName")
.DisplayExpr("customerAbbr")
.ValueExpr("customerID")
.ShowClearButton(true)
);
Back-end code (port 7006)
public async Task<LoadResult> GetBasicListAsync(DataSourceLoadOptions loadOptions)
{
int companyId = 1;
var customers = await _customerRepository.GetQueryableAsync();
var query = (from c in customers
where c.CompanyID == companyId
select new
{
c.CustomerID,
c.CustomerAbbr,
c.CustomerName,
c.Address
});
return await DataSourceLoader.LoadAsync(query, loadOptions);
}
DataSourceLoadOptions properties:
{
"requireTotalCount": true,
"requireGroupCount": true,
"isCountQuery": true,
"isSummaryQuery": true,
"skip": 0,
"take": 0,
"sort": [
{
"selector": "string",
"desc": true
}
],
"group": [
{
"selector": "string",
"desc": true,
"groupInterval": "string",
"isExpanded": true
}
],
"filter": [
"string"
],
"totalSummary": [
{
"selector": "string",
"summaryType": "string"
}
],
"groupSummary": [
{
"selector": "string",
"summaryType": "string"
}
],
"select": [
"string"
],
"preSelect": [
"string"
],
"remoteSelect": true,
"remoteGrouping": true,
"expandLinqSumType": true,
"primaryKey": [
"string"
],
"defaultSort": "string",
"stringToLower": true,
"paginateViaPrimaryKey": true,
"sortByPrimaryKey": true,
"allowAsyncOverSync": true
}
YARP config (port 7500)
{
"ReverseProxy": {
"Routes": {
"Customer Service": {
"ClusterId": "customerCluster",
"Match": {
"Path": "/api/customer-service/{**everything}"
}
}
},
"Clusters": {
"customerCluster": {
"Destinations": {
"destination1": {
"Address": "https://localhost:7006"
}
}
}
}
}
}
When running my solution, in Chrome Developer tool, I see client sent correct request like this: https://localhost:7004/api/customer-service/customer/basic-list?skip=0&take=10
but on the gateway, it only received this url:
2023-02-17 16:36:07.006 +07:00 [INF] Request starting HTTP/1.1 GET https://localhost:7500/api/customer-service/customer/basic-list?api-version=1.0 - -
2023-02-17 16:36:07.007 +07:00 [INF] Executing endpoint 'Customer Service'
2023-02-17 16:36:07.007 +07:00 [INF] Proxying to https://localhost:7006/api/customer-service/customer/basic-list?api-version=1.0 HTTP/2 RequestVersionOrLower no-streaming
2023-02-17 16:36:07.043 +07:00 [INF] Received HTTP/2.0 response 200.
The part skip=0&take=10
was removed and I don't know why? Any help is highly appreciated.