/*
* Copyright (c) 2023 Vaughn Nugent
*
* Library: VNLib
* Package: VNLib.Plugins.Essentials.ServiceStack
* File: IVirtualHostHooks.cs
*
* IVirtualHostHooks.cs is part of VNLib.Plugins.Essentials.ServiceStack which is part of the larger
* VNLib collection of libraries and utilities.
*
* VNLib.Plugins.Essentials.ServiceStack is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero 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.ServiceStack 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 Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see https://www.gnu.org/licenses/.
*/
using System.Net;
using System.Threading.Tasks;
using VNLib.Net.Http;
namespace VNLib.Plugins.Essentials.ServiceStack
{
///
/// Represents a type that will handle http events for a virtual host
///
public interface IVirtualHostHooks
{
///
///
/// Called when the server intends to process a file and requires translation from a
/// uri path to a usable filesystem path
///
///
/// NOTE: This function must be thread-safe!
///
///
/// The path requested by the request
/// The translated and filtered filesystem path used to identify the file resource
string TranslateResourcePath(string requestPath);
///
///
/// When an error occurs and is handled by the library, this event is invoked
///
///
/// NOTE: This function must be thread-safe!
///
///
/// The error code that was created during processing
/// The active IHttpEvent representing the faulted request
/// A value indicating if the entity was proccsed by this call
bool ErrorHandler(HttpStatusCode errorCode, IHttpEvent entity);
///
/// For pre-processing a request entity before all endpoint lookups are performed
///
/// The http entity to process
/// The results to return to the file processor, or null of the entity requires further processing
ValueTask PreProcessEntityAsync(HttpEntity entity);
///
/// Allows for post processing of a selected for the given entity
///
/// The http entity to process
/// The selected file processing routine for the given request
void PostProcessFile(HttpEntity entity, in FileProcessArgs chosenRoutine);
}
}