Add support for Cors (#714)

This commit is contained in:
Stef Heyenrath
2022-01-24 12:26:19 +01:00
committed by GitHub
parent d6c36bc23b
commit ccd433b202
15 changed files with 173 additions and 35 deletions

View File

@@ -1,5 +1,6 @@
using System.Text.RegularExpressions;
using WireMock.Handlers;
using WireMock.Types;
namespace WireMock.Admin.Settings
{
@@ -53,5 +54,10 @@ namespace WireMock.Admin.Settings
/// Save unmatched requests to a file using the <see cref="IFileSystemHandler"/>. (default set to false).
/// </summary>
public bool? SaveUnmatchedRequests { get; set; }
/// <summary>
/// Policies to use when using CORS. By default CORS is disabled. [Optional]
/// </summary>
public string CorsPolicyOptions { get; set; }
}
}

View File

@@ -0,0 +1,36 @@
using System;
namespace WireMock.Types
{
/// <summary>
/// Policies to use when using CORS.
/// </summary>
[Flags]
public enum CorsPolicyOptions
{
/// <summary>
/// Cors is disabled
/// </summary>
None = 0,
/// <summary>
/// Ensures that the policy allows any header.
/// </summary>
AllowAnyHeader = 0b00000001,
/// <summary>
/// Ensures that the policy allows any method.
/// </summary>
AllowAnyMethod = 0b00000010,
/// <summary>
/// Ensures that the policy allows any origin.
/// </summary>
AllowAnyOrigin = 0b00000100,
/// <summary>
/// Ensures that the policy allows any header, method and origin.
/// </summary>
AllowAll = AllowAnyHeader | AllowAnyMethod | AllowAnyOrigin
}
}