-
-
Notifications
You must be signed in to change notification settings - Fork 200
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
15 changed files
with
430 additions
and
404 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,15 +1,14 @@ | ||
namespace WireMock.Owin | ||
namespace WireMock.Owin; | ||
|
||
internal struct HostUrlDetails | ||
{ | ||
internal class HostUrlDetails | ||
{ | ||
public bool IsHttps { get; set; } | ||
public bool IsHttps { get; set; } | ||
|
||
public string Url { get; set; } | ||
public string Url { get; set; } | ||
|
||
public string Protocol { get; set; } | ||
public string Protocol { get; set; } | ||
|
||
public string Host { get; set; } | ||
public string Host { get; set; } | ||
|
||
public int Port { get; set; } | ||
} | ||
public int Port { get; set; } | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,46 +1,47 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Generic; | ||
using WireMock.Util; | ||
|
||
namespace WireMock.Owin | ||
namespace WireMock.Owin; | ||
|
||
internal class HostUrlOptions | ||
{ | ||
internal class HostUrlOptions | ||
{ | ||
private const string LOCALHOST = "localhost"; | ||
private const string LOCALHOST = "localhost"; | ||
|
||
public ICollection<string> Urls { get; set; } | ||
public ICollection<string>? Urls { get; set; } | ||
|
||
public int? Port { get; set; } | ||
public int? Port { get; set; } | ||
|
||
public bool UseSSL { get; set; } | ||
public bool UseSSL { get; set; } | ||
|
||
public ICollection<HostUrlDetails> GetDetails() | ||
public ICollection<HostUrlDetails> GetDetails() | ||
{ | ||
var list = new List<HostUrlDetails>(); | ||
if (Urls == null) | ||
{ | ||
var list = new List<HostUrlDetails>(); | ||
if (Urls == null) | ||
{ | ||
int port = Port > 0 ? Port.Value : FindFreeTcpPort(); | ||
string protocol = UseSSL ? "https" : "http"; | ||
list.Add(new HostUrlDetails { IsHttps = UseSSL, Url = $"{protocol}://{LOCALHOST}:{port}", Protocol = protocol, Host = LOCALHOST, Port = port }); | ||
} | ||
else | ||
int port = Port > 0 ? Port.Value : FindFreeTcpPort(); | ||
string protocol = UseSSL ? "https" : "http"; | ||
list.Add(new HostUrlDetails { IsHttps = UseSSL, Url = $"{protocol}://{LOCALHOST}:{port}", Protocol = protocol, Host = LOCALHOST, Port = port }); | ||
} | ||
else | ||
{ | ||
foreach (string url in Urls) | ||
{ | ||
foreach (string url in Urls) | ||
if (PortUtils.TryExtract(url, out bool isHttps, out var protocol, out var host, out int port)) | ||
{ | ||
PortUtils.TryExtract(url, out bool isHttps, out string protocol, out string host, out int port); | ||
list.Add(new HostUrlDetails { IsHttps = isHttps, Url = url, Protocol = protocol, Host = host, Port = port }); | ||
} | ||
} | ||
|
||
return list; | ||
} | ||
|
||
private int FindFreeTcpPort() | ||
{ | ||
return list; | ||
} | ||
|
||
private static int FindFreeTcpPort() | ||
{ | ||
#if USE_ASPNETCORE || NETSTANDARD2_0 || NETSTANDARD2_1 | ||
return 0; | ||
return 0; | ||
#else | ||
return PortUtils.FindFreeTcpPort(); | ||
return PortUtils.FindFreeTcpPort(); | ||
#endif | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,6 @@ | ||
namespace WireMock.Owin | ||
namespace WireMock.Owin; | ||
|
||
internal interface IMappingMatcher | ||
{ | ||
internal interface IMappingMatcher | ||
{ | ||
(MappingMatcherResult Match, MappingMatcherResult Partial) FindBestMatch(RequestMessage request); | ||
} | ||
(MappingMatcherResult? Match, MappingMatcherResult? Partial) FindBestMatch(RequestMessage request); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,36 +1,35 @@ | ||
using System.Collections.Generic; | ||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
using System; | ||
|
||
namespace WireMock.Owin | ||
namespace WireMock.Owin; | ||
|
||
interface IOwinSelfHost | ||
{ | ||
interface IOwinSelfHost | ||
{ | ||
/// <summary> | ||
/// Gets a value indicating whether this server is started. | ||
/// </summary> | ||
/// <value> | ||
/// <c>true</c> if this server is started; otherwise, <c>false</c>. | ||
/// </value> | ||
bool IsStarted { get; } | ||
/// <summary> | ||
/// Gets a value indicating whether this server is started. | ||
/// </summary> | ||
/// <value> | ||
/// <c>true</c> if this server is started; otherwise, <c>false</c>. | ||
/// </value> | ||
bool IsStarted { get; } | ||
|
||
/// <summary> | ||
/// Gets the urls. | ||
/// </summary> | ||
List<string> Urls { get; } | ||
/// <summary> | ||
/// Gets the urls. | ||
/// </summary> | ||
List<string> Urls { get; } | ||
|
||
/// <summary> | ||
/// Gets the ports. | ||
/// </summary> | ||
List<int> Ports { get; } | ||
/// <summary> | ||
/// Gets the ports. | ||
/// </summary> | ||
List<int> Ports { get; } | ||
|
||
/// <summary> | ||
/// The exception occurred when the host is running | ||
/// </summary> | ||
Exception RunningException { get; } | ||
/// <summary> | ||
/// The exception occurred when the host is running. | ||
/// </summary> | ||
Exception? RunningException { get; } | ||
|
||
Task StartAsync(); | ||
Task StartAsync(); | ||
|
||
Task StopAsync(); | ||
} | ||
Task StopAsync(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.