uff, lot of work

This commit is contained in:
Schedel Pascal
2024-08-02 11:47:33 +02:00
parent ca8213d6ee
commit 82485da5d2
23 changed files with 352 additions and 47 deletions

View File

@@ -1,25 +1,17 @@
namespace OwnChar.ServerNew.Api.Endpoint;
using OwnChar.Api.Packets;
namespace OwnChar.Server.Api.Endpoint;
internal class ApiBuilder(WebApplication app) : IApiBuilder
{
public void Map(string method, string pattern, Delegate action)
public void MapRequest(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();
Map(pattern + "/{request}", action);
}
public void Map(string pattern, Delegate action)
{
app.Map(pattern, action);
//app.Map(pattern, action);
app.MapPost(pattern, action);
}
}