Skip to content

Commit

Permalink
fix: use WebProxy for IONOS (#7)
Browse files Browse the repository at this point in the history
* Use webProxy for IONOS (https://www.ionos.de/hilfe/index.php?id=4426)

* Add link to help

* Cleanup
  • Loading branch information
vbreuss authored Mar 30, 2024
1 parent dbfa9dc commit 465cdde
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public async Task<IActionResult> OnPullRequestChanged(
return BadRequest($"Only public repositories from '{RepositoryOwner}' are supported!");
}
var bearerToken = _configuration.GetValue<string>("GithubBearerToken");
using var client = _clientFactory.CreateClient();
using var client = _clientFactory.CreateClient("Proxied");
client.DefaultRequestHeaders.UserAgent.Add(new ProductInfoHeaderValue("Testably", Assembly.GetExecutingAssembly().GetName().Version.ToString()));

Check warning on line 65 in Source/Testably.Server/Controllers/PullRequestStatusCheckController.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 65 in Source/Testably.Server/Controllers/PullRequestStatusCheckController.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.

Check warning on line 65 in Source/Testably.Server/Controllers/PullRequestStatusCheckController.cs

View workflow job for this annotation

GitHub Actions / build

Dereference of a possibly null reference.
client.DefaultRequestHeaders.Authorization =
new AuthenticationHeaderValue("Bearer", bearerToken);
Expand Down
18 changes: 8 additions & 10 deletions Source/Testably.Server/Program.cs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
using System.Net;
using System.Reflection;
using System.Text.Json;
using Serilog;
using ILogger = Serilog.ILogger;

namespace Testably.Server;

Expand All @@ -14,8 +14,14 @@ public static void Main(string[] args)

var builder = WebApplication.CreateBuilder(args);

// https://www.ionos.de/hilfe/index.php?id=4426
var webProxy = new WebProxy("http://winproxy.server.lan:3128");
// Add services to the container.
builder.Services.AddHttpClient();
builder.Services.AddHttpClient("Proxied")
.ConfigurePrimaryHttpMessageHandler(() => new HttpClientHandler()
{
Proxy = webProxy
});
builder.Services.AddRazorPages();
builder.Services.AddControllers()
.AddJsonOptions(o
Expand Down Expand Up @@ -47,12 +53,4 @@ public static void Main(string[] args)

app.Run();
}

private static ILogger CreateSerilogLogger()
{
var logPath = $"logs/log.txt";
return new LoggerConfiguration()
.WriteTo.File(logPath, rollingInterval: RollingInterval.Day)
.CreateLogger();
}
}

0 comments on commit 465cdde

Please sign in to comment.