mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-30 05:41:46 +02:00
Listen on more ip-address/ports (#18)
This commit is contained in:
@@ -33,9 +33,9 @@ namespace WireMock.Server
|
||||
private TimeSpan _requestProcessingDelay = TimeSpan.Zero;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the port.
|
||||
/// Gets the urls.
|
||||
/// </summary>
|
||||
public int Port { get; }
|
||||
public string[] Urls { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the request logs.
|
||||
@@ -82,6 +82,19 @@ namespace WireMock.Server
|
||||
return new FluentMockServer(false, port, ssl);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start this FluentMockServer.
|
||||
/// </summary>
|
||||
/// <param name="urls">The urls to listen on.</param>
|
||||
/// <returns>The <see cref="FluentMockServer"/>.</returns>
|
||||
[PublicAPI]
|
||||
public static FluentMockServer Start(params string[] urls)
|
||||
{
|
||||
Check.NotEmpty(urls, nameof(urls));
|
||||
|
||||
return new FluentMockServer(false, urls);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Start this FluentMockServer with the admin interface.
|
||||
/// </summary>
|
||||
@@ -99,19 +112,37 @@ namespace WireMock.Server
|
||||
return new FluentMockServer(true, port, ssl);
|
||||
}
|
||||
|
||||
private FluentMockServer(bool startAdmin, int port, bool ssl)
|
||||
/// <summary>
|
||||
/// Start this FluentMockServer with the admin interface.
|
||||
/// </summary>
|
||||
/// <param name="urls">The urls.</param>
|
||||
/// <returns>The <see cref="FluentMockServer"/>.</returns>
|
||||
[PublicAPI]
|
||||
public static FluentMockServer StartWithAdminInterface(params string[] urls)
|
||||
{
|
||||
string protocol = ssl ? "https" : "http";
|
||||
_httpServer = new TinyHttpServer(protocol + "://localhost:" + port + "/", HandleRequestAsync);
|
||||
Port = port;
|
||||
Check.NotEmpty(urls, nameof(urls));
|
||||
|
||||
return new FluentMockServer(true, urls);
|
||||
}
|
||||
|
||||
private FluentMockServer(bool startAdminInterface, int port, bool ssl) : this(startAdminInterface, (ssl ? "https" : "http") + "://localhost:" + port + "/")
|
||||
{
|
||||
}
|
||||
|
||||
private FluentMockServer(bool startAdminInterface, params string[] urls)
|
||||
{
|
||||
Urls = urls;
|
||||
|
||||
_httpServer = new TinyHttpServer(urls, HandleRequestAsync);
|
||||
_httpServer.Start();
|
||||
|
||||
if (startAdmin)
|
||||
if (startAdminInterface)
|
||||
{
|
||||
InitAdmin();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Stop this server.
|
||||
/// </summary>
|
||||
|
||||
Reference in New Issue
Block a user