diff options
Diffstat (limited to 'lib/Plugins.Essentials')
6 files changed, 109 insertions, 1 deletions
diff --git a/lib/Plugins.Essentials/src/Accounts/AccountUtils.cs b/lib/Plugins.Essentials/src/Accounts/AccountUtils.cs index e819e6c..7f3ae40 100644 --- a/lib/Plugins.Essentials/src/Accounts/AccountUtils.cs +++ b/lib/Plugins.Essentials/src/Accounts/AccountUtils.cs @@ -478,7 +478,7 @@ namespace VNLib.Plugins.Essentials.Accounts /// <param name="session"></param> /// <param name="value">True for a local account, false otherwise</param> [MethodImpl(MethodImplOptions.AggressiveInlining)] - public static void HasLocalAccount(this in SessionInfo session, bool value) => session[LOCAL_ACCOUNT_ENTRY] = value ? "1" : null; + public static void HasLocalAccount(this in SessionInfo session, bool value) => session[LOCAL_ACCOUNT_ENTRY] = value ? "1" : null!; /// <summary> /// Gets a value indicating if the session belongs to a local user account diff --git a/lib/Plugins.Essentials/src/Endpoints/IVirtualEndpoint.cs b/lib/Plugins.Essentials/src/Endpoints/IVirtualEndpoint.cs new file mode 100644 index 0000000..10545cf --- /dev/null +++ b/lib/Plugins.Essentials/src/Endpoints/IVirtualEndpoint.cs @@ -0,0 +1,43 @@ +/* +* Copyright (c) 2023 Vaughn Nugent +* +* Library: VNLib +* Package: VNLib.Plugins.Essentials +* File: IVirtualEndpoint.cs +* +* IVirtualEndpoint.cs is part of VNLib.Plugins.Essentials which is part of the larger +* VNLib collection of libraries and utilities. +* +* VNLib.Plugins.Essentials is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published +* by the Free Software Foundation, either version 2 of the License, +* or (at your option) any later version. +* +* VNLib.Plugins.Essentials is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with VNLib.Plugins. If not, see http://www.gnu.org/licenses/. +*/ + +using System.Threading.Tasks; + +namespace VNLib.Plugins.Essentials.Endpoints +{ + + /// <summary> + /// Represents a virtual page which provides processing on an entity + /// </summary> + /// <typeparam name="TEntity">The entity type to process</typeparam> + public interface IVirtualEndpoint<TEntity> : IEndpoint + { + /// <summary> + /// The handler method for processing the specified location. + /// </summary> + /// <param name="entity">The current connection/session </param> + /// <returns>A <see cref="VfReturnType"/> specifying how the caller should continue processing the request</returns> + public ValueTask<VfReturnType> Process(TEntity entity); + } +}
\ No newline at end of file diff --git a/lib/Plugins.Essentials/src/Endpoints/VfReturnType.cs b/lib/Plugins.Essentials/src/Endpoints/VfReturnType.cs new file mode 100644 index 0000000..2fe29c7 --- /dev/null +++ b/lib/Plugins.Essentials/src/Endpoints/VfReturnType.cs @@ -0,0 +1,61 @@ +/* +* Copyright (c) 2023 Vaughn Nugent +* +* Library: VNLib +* Package: VNLib.Plugins.Essentials +* File: VfReturnType.cs +* +* VfReturnType.cs is part of VNLib.Plugins.Essentials which is part of the larger +* VNLib collection of libraries and utilities. +* +* VNLib.Plugins.Essentials is free software: you can redistribute it and/or modify +* it under the terms of the GNU General Public License as published +* by the Free Software Foundation, either version 2 of the License, +* or (at your option) any later version. +* +* VNLib.Plugins.Essentials is distributed in the hope that it will be useful, +* but WITHOUT ANY WARRANTY; without even the implied warranty of +* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +* General Public License for more details. +* +* You should have received a copy of the GNU General Public License +* along with VNLib.Plugins.Essentials. If not, see http://www.gnu.org/licenses/. +*/ + +namespace VNLib.Plugins.Essentials +{ + + /// <summary> + /// Represents the result of a virutal endpoint processing operation + /// </summary> + public enum VfReturnType + { + /// <summary> + /// Signals that the virtual endpoint + /// </summary> + ProcessAsFile, + /// <summary> + /// Signals that the virtual endpoint generated a response, and + /// the connection should be completed + /// </summary> + VirtualSkip, + /// <summary> + /// Signals that the virtual endpoint determined that the connection + /// should be denied. + /// </summary> + Forbidden, + /// <summary> + /// Signals that the resource the virtual endpoint was processing + /// does not exist. + /// </summary> + NotFound, + /// <summary> + /// Signals that the virutal endpoint determined the request was invalid + /// </summary> + BadRequest, + /// <summary> + /// Signals that the virtual endpoint had an error + /// </summary> + Error + } +} diff --git a/lib/Plugins.Essentials/src/EventProcessor.cs b/lib/Plugins.Essentials/src/EventProcessor.cs index 90906eb..c4659b9 100644 --- a/lib/Plugins.Essentials/src/EventProcessor.cs +++ b/lib/Plugins.Essentials/src/EventProcessor.cs @@ -39,6 +39,7 @@ using VNLib.Plugins.Essentials.Content; using VNLib.Plugins.Essentials.Sessions; using VNLib.Plugins.Essentials.Extensions; using VNLib.Plugins.Essentials.Middleware; +using VNLib.Plugins.Essentials.Endpoints; #nullable enable diff --git a/lib/Plugins.Essentials/src/IVirtualEndpointTable.cs b/lib/Plugins.Essentials/src/IVirtualEndpointTable.cs index cfe9661..c260b45 100644 --- a/lib/Plugins.Essentials/src/IVirtualEndpointTable.cs +++ b/lib/Plugins.Essentials/src/IVirtualEndpointTable.cs @@ -24,6 +24,8 @@ using System; +using VNLib.Plugins.Essentials.Endpoints; + #nullable enable namespace VNLib.Plugins.Essentials diff --git a/lib/Plugins.Essentials/src/SemiConsistentVeTable.cs b/lib/Plugins.Essentials/src/SemiConsistentVeTable.cs index d43432a..483dc35 100644 --- a/lib/Plugins.Essentials/src/SemiConsistentVeTable.cs +++ b/lib/Plugins.Essentials/src/SemiConsistentVeTable.cs @@ -29,6 +29,7 @@ using System.Threading.Tasks; using System.Collections.Generic; using VNLib.Net.Http; +using VNLib.Plugins.Essentials.Endpoints; #nullable enable |