mirror of
https://gitee.com/fudiwei/DotNetCore.SKIT.FlurlHttpClient.Wechat.git
synced 2025-12-29 18:04:42 +08:00
feat(core): 移除 IWechatClient.CreateRequest 方法
This commit is contained in:
@@ -19,20 +19,5 @@ namespace SKIT.FlurlHttpClient.Wechat
|
||||
/// </summary>
|
||||
/// <param name="configure"></param>
|
||||
public void Configure(Action<WechatClientSettings> configure);
|
||||
|
||||
/// <summary>
|
||||
/// 使用当前客户端生成一个新的 <see cref="IFlurlRequest"/> 对象。
|
||||
/// </summary>
|
||||
/// <param name="urlSegments"></param>
|
||||
/// <returns></returns>
|
||||
IFlurlRequest CreateRequest(params object[] urlSegments);
|
||||
|
||||
/// <summary>
|
||||
/// 使用当前客户端生成一个新的 <see cref="IFlurlRequest"/> 对象。
|
||||
/// </summary>
|
||||
/// <param name="method"></param>
|
||||
/// <param name="urlSegments"></param>
|
||||
/// <returns></returns>
|
||||
IFlurlRequest CreateRequest(HttpMethod method, params object[] urlSegments);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -75,33 +75,21 @@ namespace SKIT.FlurlHttpClient.Wechat
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IFlurlRequest CreateRequest(params object[] urlSegments)
|
||||
{
|
||||
return CreateRequest(HttpMethod.Get, urlSegments);
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public IFlurlRequest CreateRequest(HttpMethod method, params object[] urlSegments)
|
||||
{
|
||||
return FlurlClient.Request(urlSegments).WithVerb(method);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 异步发起请求。
|
||||
/// </summary>
|
||||
/// <param name="flurlRequest"></param>
|
||||
/// <param name="content"></param>
|
||||
/// <param name="httpContent"></param>
|
||||
/// <param name="cancellationToken"></param>
|
||||
/// <returns></returns>
|
||||
protected virtual async Task<IFlurlResponse> SendRequestAsync(IFlurlRequest flurlRequest, HttpContent? content = null, CancellationToken cancellationToken = default)
|
||||
protected virtual async Task<IFlurlResponse> SendRequestAsync(IFlurlRequest flurlRequest, HttpContent? httpContent = null, CancellationToken cancellationToken = default)
|
||||
{
|
||||
if (flurlRequest == null) throw new ArgumentNullException(nameof(flurlRequest));
|
||||
|
||||
var response = await flurlRequest
|
||||
.WithClient(FlurlClient)
|
||||
.AllowAnyHttpStatus()
|
||||
.SendAsync(flurlRequest.Verb, content, cancellationToken)
|
||||
.SendAsync(flurlRequest.Verb, httpContent, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
return response;
|
||||
}
|
||||
@@ -117,12 +105,22 @@ namespace SKIT.FlurlHttpClient.Wechat
|
||||
{
|
||||
if (flurlRequest == null) throw new ArgumentNullException(nameof(flurlRequest));
|
||||
|
||||
var response = await flurlRequest
|
||||
.WithClient(FlurlClient)
|
||||
.AllowAnyHttpStatus()
|
||||
.SendJsonAsync(flurlRequest.Verb, data, cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
return response;
|
||||
if (flurlRequest.Verb == HttpMethod.Get)
|
||||
{
|
||||
return await flurlRequest
|
||||
.WithClient(FlurlClient)
|
||||
.AllowAnyHttpStatus()
|
||||
.SendAsync(flurlRequest.Verb, cancellationToken: cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
else
|
||||
{
|
||||
return await flurlRequest
|
||||
.WithClient(FlurlClient)
|
||||
.AllowAnyHttpStatus()
|
||||
.SendJsonAsync(flurlRequest.Verb, data: data, cancellationToken: cancellationToken)
|
||||
.ConfigureAwait(false);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user