begin new and last rework
This commit is contained in:
25
OwnChar.Server/Api/Endpoint/ApiBuilder.cs
Normal file
25
OwnChar.Server/Api/Endpoint/ApiBuilder.cs
Normal file
@@ -0,0 +1,25 @@
|
||||
namespace OwnChar.ServerNew.Api.Endpoint;
|
||||
|
||||
internal class ApiBuilder(WebApplication app) : IApiBuilder
|
||||
{
|
||||
public void Map(string method, string pattern, Delegate action)
|
||||
{
|
||||
if (method == ApiRequestMethods.Get)
|
||||
app.MapGet(pattern, action);
|
||||
else if (method == ApiRequestMethods.Post)
|
||||
app.MapPost(pattern, action);
|
||||
else if (method == ApiRequestMethods.Put)
|
||||
app.MapPut(pattern, action);
|
||||
else if (method == ApiRequestMethods.Patch)
|
||||
app.MapPatch(pattern, action);
|
||||
else if (method == ApiRequestMethods.Delete)
|
||||
app.MapDelete(pattern, action);
|
||||
else
|
||||
throw new NotSupportedException();
|
||||
}
|
||||
|
||||
public void Map(string pattern, Delegate action)
|
||||
{
|
||||
app.Map(pattern, action);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user