Skip to content

Commit

Permalink
feat: 优化代码
Browse files Browse the repository at this point in the history
  • Loading branch information
nidbCN committed Jun 7, 2024
1 parent aeb8120 commit f4e7df0
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
2 changes: 1 addition & 1 deletion AliCdnSSLWorker.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<DockerDefaultTargetOS>Linux</DockerDefaultTargetOS>
<DockerfileContext>.</DockerfileContext>
<AssemblyVersion>6.0.2.1</AssemblyVersion>
<FileVersion>6.0.1.1</FileVersion>
<FileVersion>6.0.2.1</FileVersion>
</PropertyGroup>

<ItemGroup>
Expand Down
8 changes: 3 additions & 5 deletions Clients/RefreshRequestClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,9 @@ public class RefreshRequestClient

public RefreshRequestClient(HttpClient httpClient, IOptions<ApiConfig> options)
{
var ip = options.Value.IpAddress.ToString();
if (options.Value.IpAddress.Equals(IPAddress.Any))
{
ip = IPAddress.Loopback.ToString();
}
var ip = options.Value.IpAddress.Equals(IPAddress.Any)
? IPAddress.Loopback
: options.Value.IpAddress;

httpClient.BaseAddress = new($"http://{ip}:{options.Value.Port}/");
httpClient.DefaultRequestHeaders.Add(
Expand Down
9 changes: 6 additions & 3 deletions Services/RefreshRequestService.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,13 @@

namespace AliCdnSSLWorker.Services;

public class RefreshRequestService(RefreshRequestClient client)
public class RefreshRequestService(ILogger<RefreshRequestService> logger, RefreshRequestClient client)
{
public async Task Update()
=> (await client.RequestAsync())
.EnsureSuccessStatusCode();
{
logger.LogInformation("Send refresh request to {url}", client.Client.BaseAddress);
var resp = await client.RequestAsync();
resp.EnsureSuccessStatusCode();
}

}

0 comments on commit f4e7df0

Please sign in to comment.