Skip to content

Commit

Permalink
Made page and pagesize optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
erikhermansson79 committed Dec 19, 2023
1 parent 579a895 commit e2d49bf
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 5 deletions.
4 changes: 2 additions & 2 deletions Files.Api/Files.Api.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<GeneratePackageOnBuild>True</GeneratePackageOnBuild>
<VersionPrefix>1.0.1</VersionPrefix>
<VersionPrefix>1.0.2</VersionPrefix>
<!--<VersionSuffix>preview-$([System.DateTime]::UtcNow.Year.ToString()).$([System.DateTime]::UtcNow.DayOfYear.ToString()).$([System.DateTime]::UtcNow.Hour.ToString()).$([System.DateTime]::UtcNow.Minute.ToString())</VersionSuffix>-->
</PropertyGroup>

<ItemGroup>
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0-preview.7.23375.6" />
<PackageReference Include="Microsoft.Extensions.DependencyInjection.Abstractions" Version="8.0.0" />
</ItemGroup>
<ItemGroup>
<FrameworkReference Include="Microsoft.AspNetCore.App" />
Expand Down
8 changes: 5 additions & 3 deletions Files.Api/FilesApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -12,16 +12,18 @@ namespace Files.Api
{
public static class FilesApi
{
private static readonly string[] s_httpMethods = ["Get", "Head"];

Check failure on line 15 in Files.Api/FilesApi.cs

View workflow job for this annotation

GitHub Actions / Update NuGet

The feature 'collection expressions' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version.

Check failure on line 15 in Files.Api/FilesApi.cs

View workflow job for this annotation

GitHub Actions / Update NuGet

The feature 'collection expressions' is currently in Preview and *unsupported*. To use Preview features, use the 'preview' language version.

public static RouteGroupBuilder MapFiles(this IEndpointRouteBuilder routes, FilesApiOptions? options = null)
{
options ??= new FilesApiOptions();

var group = routes.MapGroup("/files").WithTags("Files");

group.MapMethods("{**path}", new[] { "Get", "Head" },
async (string? path, [FromQuery] uint page, [FromQuery] int pageSize, IFileService fileService, IHttpContextAccessor httpContextAccessor) =>
group.MapMethods("{**path}", s_httpMethods,
async (string? path, [FromQuery] uint? page, [FromQuery] int? pageSize, IFileService fileService, IHttpContextAccessor httpContextAccessor) =>
{
var contentModel = await fileService.GetContentAsync(path, page, pageSize);
var contentModel = await fileService.GetContentAsync(path, page ?? 1, pageSize ?? 20);

if (contentModel.Data == null)
{
Expand Down

0 comments on commit e2d49bf

Please sign in to comment.