mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-01-18 08:07:09 +01:00
settings
This commit is contained in:
@@ -7,6 +7,7 @@ using WireMock.Server;
|
||||
using WireMock.Settings;
|
||||
using WireMock.Validation;
|
||||
using JetBrains.Annotations;
|
||||
using Newtonsoft.Json;
|
||||
|
||||
namespace WireMock.Net.StandAlone
|
||||
{
|
||||
@@ -17,6 +18,9 @@ namespace WireMock.Net.StandAlone
|
||||
{
|
||||
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)]
|
||||
public List<string> Urls { get; set; }
|
||||
|
||||
@@ -87,16 +91,35 @@ namespace WireMock.Net.StandAlone
|
||||
|
||||
var settings = new FluentMockServerSettings
|
||||
{
|
||||
Urls = options.Urls.ToArray(),
|
||||
StartAdminInterface = options.StartAdminInterface,
|
||||
ReadStaticMappings = options.ReadStaticMappings,
|
||||
AllowPartialMapping = options.AllowPartialMapping,
|
||||
AdminUsername = options.AdminUsername,
|
||||
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))
|
||||
{
|
||||
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);
|
||||
|
||||
Console.WriteLine("WireMock.Net server listening at {0}", string.Join(" and ", server.Urls));
|
||||
|
||||
Reference in New Issue
Block a user