-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Re-organize endpoint/handler classes
- Loading branch information
Showing
5 changed files
with
73 additions
and
46 deletions.
There are no files selected for viewing
34 changes: 34 additions & 0 deletions
34
src/PackageRegistryService/API/Endpoints/PackagesEndpointsV1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
using Microsoft.AspNetCore.Http.HttpResults; | ||
using PackageRegistryService.Authentication; | ||
using Microsoft.AspNetCore.Mvc; | ||
using PackageRegistryService.API.Handlers; | ||
|
||
namespace PackageRegistryService.API.Endpoints | ||
{ | ||
public static class PackagesEndpointsV1 | ||
{ | ||
public static RouteGroupBuilder MapPackagesApiV1(this RouteGroupBuilder group) | ||
{ | ||
|
||
// packages endpoints | ||
group.MapGet("/", PackageHandlers.GetAllPackages) | ||
.WithOpenApi() | ||
.WithName("GetAllPackages"); | ||
|
||
group.MapGet("/{name}", PackageHandlers.GetLatestPackageByName) | ||
.WithOpenApi() | ||
.WithName("GetLatestPackageByName"); | ||
|
||
group.MapGet("/{name}/{version}", PackageHandlers.GetPackageByNameAndVersion) | ||
.WithOpenApi() | ||
.WithName("GetPackageByNameAndVersion"); | ||
|
||
group.MapPost("/", PackageHandlers.CreatePackage) | ||
.WithOpenApi() | ||
.WithName("CreatePackage") | ||
.AddEndpointFilter<APIKeyEndpointFilter>(); // creating packages via post requests requires an API key | ||
|
||
return group.WithTags("Validation Packages"); | ||
} | ||
} | ||
} |
17 changes: 17 additions & 0 deletions
17
src/PackageRegistryService/API/Endpoints/VerificationEndpointsV1.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
using PackageRegistryService.API.Handlers; | ||
using PackageRegistryService.Authentication; | ||
|
||
namespace PackageRegistryService.API.Endpoints | ||
{ | ||
public static class VerificationEndpointsV1 | ||
{ | ||
public static RouteGroupBuilder MapVerificationApiV1(this RouteGroupBuilder group) | ||
{ | ||
group.MapPost("/{name}/{version}", VerificationHandlers.Verify) | ||
.WithOpenApi() | ||
.WithName("Verify"); | ||
|
||
return group.WithTags("Content Verification"); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
src/PackageRegistryService/API/Handlers/VerificationHandlers.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
using Microsoft.AspNetCore.Http.HttpResults; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace PackageRegistryService.API.Handlers | ||
{ | ||
public class VerificationHandlers | ||
{ | ||
public static async Task<Results<Ok, UnprocessableEntity>> Verify(string name, string version, [FromBody] string hash) | ||
{ | ||
return TypedResults.UnprocessableEntity(); | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters