using System;
using EmbedIO.Internal;
namespace EmbedIO
{
///
/// Provides standard request handler callbacks.
///
///
public static class RequestHandler
{
///
/// Returns an exception object that, when thrown from a module's
/// HandleRequestAsync method, will cause the HTTP context
/// to be passed down along the module chain, regardless of the value of the module's
/// IsFinalHandler property.
///
/// A newly-created .
public static Exception PassThrough() => new RequestHandlerPassThroughException();
///
/// Returns a that unconditionally sends a 401 Unauthorized response.
///
/// A message to include in the response.
/// A .
public static RequestHandlerCallback ThrowUnauthorized(string? message = null)
=> _ => throw HttpException.Unauthorized(message);
///
/// Returns a that unconditionally sends a 403 Forbidden response.
///
/// A message to include in the response.
/// A .
public static RequestHandlerCallback ThrowForbidden(string? message = null)
=> _ => throw HttpException.Forbidden(message);
///
/// Returns a that unconditionally sends a 400 Bad Request response.
///
/// A message to include in the response.
/// A .
public static RequestHandlerCallback ThrowBadRequest(string? message = null)
=> _ => throw HttpException.BadRequest(message);
///
/// Returns a that unconditionally sends a 404 Not Found response.
///
/// A message to include in the response.
/// A .
public static RequestHandlerCallback ThrowNotFound(string? message = null)
=> _ => throw HttpException.NotFound(message);
///
/// Returns a that unconditionally sends a 405 Method Not Allowed response.
///
/// A message to include in the response.
/// A .
public static RequestHandlerCallback ThrowMethodNotAllowed(string? message = null)
=> _ => throw HttpException.MethodNotAllowed(message);
}
}