party migrate to Pilz.Net

This commit is contained in:
2024-08-22 15:12:57 +02:00
parent 1efc4fd77a
commit 255ba2348d
12 changed files with 30 additions and 137 deletions

View File

@@ -1,13 +0,0 @@
namespace OwnChar.Server.Api.Endpoint;
internal class ApiBuilder : IApiBuilder
{
private readonly Dictionary<ApiMapInfo, Delegate> handlers = [];
public IReadOnlyDictionary<ApiMapInfo, Delegate> Handlers => handlers;
public void Map(string pattern, Delegate action)
{
handlers.Add(new(pattern, "POST"), action);
}
}

View File

@@ -1,3 +0,0 @@
namespace OwnChar.Server.Api.Endpoint;
public record struct ApiMapInfo(string Pattern, string Method);

View File

@@ -1,12 +0,0 @@
using System.Net;
namespace OwnChar.Server.Api.Endpoint;
public static class ApiRequestMethods
{
public static string Get => WebRequestMethods.Http.Get;
public static string Put => WebRequestMethods.Http.Put;
public static string Post => WebRequestMethods.Http.Post;
public static string Patch => "PATCH";
public static string Delete => "DELETE";
}

View File

@@ -1,7 +1,4 @@
using OwnChar.Server.Api;
using OwnChar.Server.Api.Endpoint;
namespace OwnChar.Server.Api.Endpoint.Implementations;
namespace OwnChar.Server.Api.Endpoint;
internal class CharactersApi(IServer server) : IApiEndpoint
{

View File

@@ -7,7 +7,7 @@ using OwnChar.Data.Model.Client;
using OwnChar.Server.Data.Model;
using OwnChar.Server.Extensions;
namespace OwnChar.Server.Api.Endpoint.Implementations;
namespace OwnChar.Server.Api.Endpoint;
internal class GroupsApi(IServer server) : IApiEndpoint
{
@@ -58,7 +58,7 @@ internal class GroupsApi(IServer server) : IApiEndpoint
return TypedResults.Unauthorized();
var group = new GroupDb();
if (!string.IsNullOrWhiteSpace(request.Name))
group.Name = request.Name;

View File

@@ -1,8 +0,0 @@
namespace OwnChar.Server.Api.Endpoint;
public interface IApiBuilder
{
public IReadOnlyDictionary<ApiMapInfo, Delegate> Handlers { get; }
void Map(string path, Delegate action);
}

View File

@@ -3,7 +3,7 @@ using OwnChar.Api.Packets.General;
using OwnChar.Server.Data.Model;
using OwnChar.Server.Extensions;
namespace OwnChar.Server.Api.Endpoint.Implementations;
namespace OwnChar.Server.Api.Endpoint;
internal class LoginApi(ServerContext server) : IApiEndpoint
{

View File

@@ -1,6 +1,4 @@
using OwnChar.Server.Api;
namespace OwnChar.Server.Api.Endpoint.Implementations;
namespace OwnChar.Server.Api.Endpoint;
internal class UsersApi(IServer server) : IApiEndpoint
{

View File

@@ -1,16 +1,15 @@
using Microsoft.EntityFrameworkCore;
using OwnChar.Data.Model.Base;
using Pilz.Configuration;
using Pilz.Net.Api;
using System.Diagnostics.CodeAnalysis;
using ILogger = Castle.Core.Logging.ILogger;
namespace OwnChar.Server.Api;
public interface IServer
public interface IServer : IApiServer
{
ISettings Settings { get; }
DbContext? Data { get; }
ILogger Log { get; }
[MemberNotNull(nameof(Data))]
void CheckLogin(string secret);

View File

@@ -3,9 +3,9 @@ using Pilz.Plugins.Advanced;
namespace OwnChar.Server.Api.Plugins;
public abstract class ApiEndpointFeature(string identifier) : PluginFeature(FeatureType, identifier), IApiEndpoint
public abstract class ApiEndpointFeature(string identifier) : PluginFeature(FeatureType, identifier)
{
public static string FeatureType => "ownchar.server.apiep";
public abstract void Initialize(IApiBuilder builder);
public abstract void OnServerInit(IServer init);
}