-
-
Notifications
You must be signed in to change notification settings - Fork 3.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93bf064
commit 3847651
Showing
7 changed files
with
185 additions
and
85 deletions.
There are no files selected for viewing
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
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
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,60 @@ | ||
namespace CleanArchitecture.WebUI.Infrastructure; | ||
|
||
public abstract class AbstractEndpoint : IEndpoint | ||
{ | ||
public abstract void Map(WebApplication app); | ||
|
||
public string Name => GetType().Name; | ||
|
||
public string Group => GetType().Namespace!.Split(".")[^1]; | ||
|
||
public string BaseRoute => $"/api/{Group}/"; | ||
|
||
public RouteHandlerBuilder MapGet(WebApplication app, Delegate handler) => MapGet(app, "", handler); | ||
|
||
public RouteHandlerBuilder MapGet(WebApplication app, string pattern, Delegate handler, bool withDefaults = true) | ||
{ | ||
var builder = app.MapGet(BuildRoutePattern(pattern), handler); | ||
|
||
if (withDefaults) | ||
{ | ||
builder.WithDefaults(this); | ||
} | ||
|
||
return builder; | ||
} | ||
|
||
public RouteHandlerBuilder MapPost(WebApplication app, Delegate handler) => MapPost(app, "", handler); | ||
|
||
public RouteHandlerBuilder MapPost(WebApplication app, string pattern, Delegate handler) | ||
{ | ||
return app.MapPost(BuildRoutePattern(pattern), handler) | ||
.WithDefaults(this); | ||
} | ||
|
||
public RouteHandlerBuilder MapPut(WebApplication app, Delegate handler) => MapPut(app, "", handler); | ||
|
||
public RouteHandlerBuilder MapPut(WebApplication app, string pattern, Delegate handler) | ||
{ | ||
return app.MapPut(BuildRoutePattern(pattern), handler) | ||
.WithDefaults(this); | ||
} | ||
|
||
public RouteHandlerBuilder MapDelete(WebApplication app, Delegate handler) => MapDelete(app, "", handler); | ||
|
||
public RouteHandlerBuilder MapDelete(WebApplication app, string pattern, Delegate handler) | ||
{ | ||
return app.MapDelete(BuildRoutePattern(pattern), handler) | ||
.WithDefaults(this); | ||
} | ||
|
||
private string BuildRoutePattern(string pattern) | ||
{ | ||
if (!pattern.StartsWith("/")) | ||
{ | ||
pattern = $"{BaseRoute}{pattern}"; | ||
} | ||
|
||
return pattern; | ||
} | ||
} |
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
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,16 @@ | ||
using Microsoft.AspNetCore.ApiAuthorization.IdentityServer; | ||
using Microsoft.AspNetCore.Mvc; | ||
|
||
namespace CleanArchitecture.WebUI.OidcConfiguration; | ||
|
||
public class OidcConfiguration : AbstractEndpoint | ||
{ | ||
public override void Map(WebApplication app) | ||
{ | ||
MapGet(app, "/_configuration/{clientId}", (IClientRequestParametersProvider clientRequestParametersProvider, HttpContext context, string clientId) => | ||
{ | ||
var parameters = clientRequestParametersProvider.GetClientParameters(context, clientId); | ||
return Results.Ok(parameters); | ||
}, withDefaults: false).ExcludeFromDescription(); | ||
} | ||
} |
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
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