mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-04-18 15:10:17 +02:00
settings
This commit is contained in:
@@ -7,6 +7,7 @@ using WireMock.Server;
|
|||||||
using WireMock.Settings;
|
using WireMock.Settings;
|
||||||
using WireMock.Validation;
|
using WireMock.Validation;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
|
using Newtonsoft.Json;
|
||||||
|
|
||||||
namespace WireMock.Net.StandAlone
|
namespace WireMock.Net.StandAlone
|
||||||
{
|
{
|
||||||
@@ -17,6 +18,9 @@ namespace WireMock.Net.StandAlone
|
|||||||
{
|
{
|
||||||
private class Options
|
private class Options
|
||||||
{
|
{
|
||||||
|
[ValueArgument(typeof(int), "Port", Description = "Port to listen on.", Optional = true)]
|
||||||
|
public int? Port { get; set; }
|
||||||
|
|
||||||
[ValueArgument(typeof(string), "Urls", Description = "URL(s) to listen on.", Optional = true, AllowMultiple = true)]
|
[ValueArgument(typeof(string), "Urls", Description = "URL(s) to listen on.", Optional = true, AllowMultiple = true)]
|
||||||
public List<string> Urls { get; set; }
|
public List<string> Urls { get; set; }
|
||||||
|
|
||||||
@@ -87,16 +91,35 @@ namespace WireMock.Net.StandAlone
|
|||||||
|
|
||||||
var settings = new FluentMockServerSettings
|
var settings = new FluentMockServerSettings
|
||||||
{
|
{
|
||||||
Urls = options.Urls.ToArray(),
|
|
||||||
StartAdminInterface = options.StartAdminInterface,
|
StartAdminInterface = options.StartAdminInterface,
|
||||||
ReadStaticMappings = options.ReadStaticMappings,
|
ReadStaticMappings = options.ReadStaticMappings,
|
||||||
AllowPartialMapping = options.AllowPartialMapping,
|
AllowPartialMapping = options.AllowPartialMapping,
|
||||||
AdminUsername = options.AdminUsername,
|
AdminUsername = options.AdminUsername,
|
||||||
AdminPassword = options.AdminPassword,
|
AdminPassword = options.AdminPassword,
|
||||||
RequestLogExpirationDuration = options.RequestLogExpirationDuration,
|
MaxRequestLogCount = options.MaxRequestLogCount,
|
||||||
MaxRequestLogCount = options.MaxRequestLogCount
|
RequestLogExpirationDuration = options.RequestLogExpirationDuration
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
if (options.Port != null)
|
||||||
|
{
|
||||||
|
settings.Port = options.Port;
|
||||||
|
}
|
||||||
|
else if (options.Urls != null)
|
||||||
|
{
|
||||||
|
settings.Urls = options.Urls.ToArray();
|
||||||
|
}
|
||||||
|
|
||||||
|
// if (options.MaxRequestLogCount > 0)
|
||||||
|
// {
|
||||||
|
// settings.MaxRequestLogCount = options.MaxRequestLogCount;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// if (options.RequestLogExpirationDuration > 0)
|
||||||
|
// {
|
||||||
|
// settings.RequestLogExpirationDuration = options.RequestLogExpirationDuration;
|
||||||
|
// }
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(options.ProxyURL))
|
if (!string.IsNullOrEmpty(options.ProxyURL))
|
||||||
{
|
{
|
||||||
settings.ProxyAndRecordSettings = new ProxyAndRecordSettings
|
settings.ProxyAndRecordSettings = new ProxyAndRecordSettings
|
||||||
@@ -107,6 +130,8 @@ namespace WireMock.Net.StandAlone
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Console.WriteLine("WireMock.Net server settings {0}", JsonConvert.SerializeObject(settings, Formatting.Indented));
|
||||||
|
|
||||||
FluentMockServer server = Start(settings);
|
FluentMockServer server = Start(settings);
|
||||||
|
|
||||||
Console.WriteLine("WireMock.Net server listening at {0}", string.Join(" and ", server.Urls));
|
Console.WriteLine("WireMock.Net server listening at {0}", string.Join(" and ", server.Urls));
|
||||||
|
|||||||
Reference in New Issue
Block a user