Skip to content

Commit

Permalink
Update to dotnet 8
Browse files Browse the repository at this point in the history
  • Loading branch information
ffried committed Nov 20, 2023
1 parent f93962b commit 2a45024
Show file tree
Hide file tree
Showing 7 changed files with 19 additions and 17 deletions.
4 changes: 2 additions & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM mcr.microsoft.com/dotnet/sdk:7.0-jammy as buildnode
FROM mcr.microsoft.com/dotnet/sdk:8.0-jammy as buildnode

ARG VERSION

Expand Down Expand Up @@ -26,7 +26,7 @@ RUN unset VERSION; \



FROM mcr.microsoft.com/dotnet/aspnet:7.0-jammy
FROM mcr.microsoft.com/dotnet/aspnet:8.0-jammy

ARG VERSION

Expand Down
8 changes: 6 additions & 2 deletions server/SensorServer/Controllers/MeasurementsController.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,14 +54,18 @@ public async Task<ActionResult<Measurement>> GetLatestMeasurement([FromQuery] st

[HttpGet]
[Route("counts")]
public async Task<MeasurementCounts> GetMeasurementCounts([FromQuery] DateTime? start, [FromQuery] DateTime? stop)
public async Task<MeasurementCounts> GetMeasurementCounts(
[FromQuery] DateTime? start,
[FromQuery] DateTime? stop)
{
return await _measurementsRepository.GetMeasurementCounts(start, stop);
}

[HttpGet]
[Route("statistics")]
public async Task<MeasurementStatistics> GetMeasurementStatistics([FromQuery] string? location, [FromQuery] DateTime? start,
public async Task<MeasurementStatistics> GetMeasurementStatistics(
[FromQuery] string? location,
[FromQuery] DateTime? start,
[FromQuery] DateTime? stop)
{
return await _measurementsRepository.GetMeasurementStatistics(location, start, stop);
Expand Down
3 changes: 1 addition & 2 deletions server/SensorServer/Helpers/HeatIndexCalculator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,7 @@ public static double CalculateHeatIndexInFahrenheit(this Measurement measurement
switch (humidityPercent)
{
case < 13 when fahrenheit is >= 80 and <= 112:
heatIndex -= (13 - humidityPercent) * 0.25 *
Math.Sqrt((17 - Math.Abs(fahrenheit - 95)) * 0.05882);
heatIndex -= (13 - humidityPercent) * 0.25 * Math.Sqrt((17 - Math.Abs(fahrenheit - 95)) * 0.05882);
break;
case > 85 when fahrenheit is >= 80 and <= 87:
heatIndex += (humidityPercent - 85) * 0.1 * ((87 - fahrenheit) * 0.2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,16 +14,15 @@ public class SimpleTokenAuthenticationHandler : AuthenticationHandler<SimpleToke
{
public SimpleTokenAuthenticationHandler(IOptionsMonitor<SimpleTokenAuthenticationOptions> options,
ILoggerFactory logger,
UrlEncoder encoder,
ISystemClock clock) : base(options, logger, encoder, clock)
UrlEncoder encoder) : base(options, logger, encoder)
{
}

protected override Task<AuthenticateResult> HandleAuthenticateAsync()
{
if (!Request.Headers.Authorization.Any()) return Task.FromResult(AuthenticateResult.NoResult());
if (Request.Headers.Authorization.Count == 0) return Task.FromResult(AuthenticateResult.NoResult());
var authHeader = Request.Headers.Authorization[0];
if (authHeader == null || !authHeader.ToLower().StartsWith("bearer "))
if (authHeader == null || !authHeader.StartsWith("bearer ", StringComparison.CurrentCultureIgnoreCase))
return Task.FromResult(AuthenticateResult.Fail("Unauthorized"));
var token = authHeader["bearer".Length..].Trim();
if (!Options.AllowedTokens.Contains(token))
Expand Down
2 changes: 1 addition & 1 deletion server/SensorServer/Models/SortDirection.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,5 +2,5 @@ namespace SensorServer.Models;

public enum SortDirection
{
Ascending, Descending
Ascending, Descending,
}
2 changes: 1 addition & 1 deletion server/SensorServer/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@
Id = "Bearer",
},
},
new string[] { }
Array.Empty<string>()
},
});
});
Expand Down
10 changes: 5 additions & 5 deletions server/SensorServer/SensorServer.csproj
Original file line number Diff line number Diff line change
@@ -1,19 +1,19 @@
<Project Sdk="Microsoft.NET.Sdk.Web">

<PropertyGroup>
<TargetFramework>net7.0</TargetFramework>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="7.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="7.0.13">
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore" Version="8.0.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="7.0.13" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Sqlite" Version="8.0.0" />
<PackageReference Include="Swashbuckle.AspNetCore" Version="6.5.0" />
</ItemGroup>

Expand Down

0 comments on commit 2a45024

Please sign in to comment.