Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add AbpHttpClientStaticProxyingOptions. #15851

Merged
merged 1 commit into from
Mar 2, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Add AbpHttpClientStaticProxyingOptions.
maliming committed Mar 2, 2023

Partially verified

This commit is signed with the committer’s verified signature.
gsmet’s contribution has been verified via GPG key.
We cannot verify signatures from co-authors, and some of the co-authors attributed to this commit require their commits to be signed.
commit 4f183560a09cd2b8917680e146d2f1807a75d466
Original file line number Diff line number Diff line change
@@ -6,13 +6,15 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc.ActionConstraints;
using Microsoft.AspNetCore.Mvc.ApplicationModels;
using Microsoft.AspNetCore.Mvc.ModelBinding;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Volo.Abp.Application.Services;
using Volo.Abp.AspNetCore.Mvc;
using Volo.Abp.AspNetCore.Mvc.Conventions;
using Volo.Abp.DependencyInjection;
using Volo.Abp.Http.Client.ClientProxying;
using Volo.Abp.Http.Client.StaticProxying;
using Volo.Abp.Http.Modeling;
using Volo.Abp.Reflection;

@@ -24,14 +26,17 @@ public class AbpHttpClientProxyServiceConvention : AbpServiceConvention
protected readonly IClientProxyApiDescriptionFinder ClientProxyApiDescriptionFinder;
protected readonly List<ControllerModel> ControllerWithAttributeRoute;
protected readonly List<ActionModel> ActionWithAttributeRoute;
protected readonly AbpHttpClientStaticProxyingOptions StaticProxyingOptions;

public AbpHttpClientProxyServiceConvention(
IOptions<AbpAspNetCoreMvcOptions> options,
IConventionalRouteBuilder conventionalRouteBuilder,
IClientProxyApiDescriptionFinder clientProxyApiDescriptionFinder)
IClientProxyApiDescriptionFinder clientProxyApiDescriptionFinder,
IOptions<AbpHttpClientStaticProxyingOptions> staticProxyingOptions)
: base(options, conventionalRouteBuilder)
{
ClientProxyApiDescriptionFinder = clientProxyApiDescriptionFinder;
StaticProxyingOptions = staticProxyingOptions.Value;
ControllerWithAttributeRoute = new List<ControllerModel>();
ActionWithAttributeRoute = new List<ActionModel>();
}
@@ -73,6 +78,27 @@ protected override void ApplyForControllers(ApplicationModel application)
}
}

protected override void ConfigureParameters(ControllerModel controller)
{
foreach (var action in controller.Actions)
{
foreach (var prm in action.Parameters)
{
if (prm.BindingInfo != null)
{
continue;
}

if (StaticProxyingOptions.BindingFromQueryTypes.Contains(prm.ParameterInfo.ParameterType))
{
prm.BindingInfo = BindingInfo.GetBindingInfo(new[] { new FromQueryAttribute() });
}
}
}

base.ConfigureParameters(controller);
}

protected virtual bool ShouldBeRemove(ApplicationModel application, ControllerModel controllerModel)
{
return application.Controllers
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
using System;
using System.Collections.Generic;

namespace Volo.Abp.Http.Client.StaticProxying;

public class AbpHttpClientStaticProxyingOptions
{
public List<Type> BindingFromQueryTypes { get; }

public AbpHttpClientStaticProxyingOptions()
{
BindingFromQueryTypes = new List<Type>();
}
}