-
-
Notifications
You must be signed in to change notification settings - Fork 209
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fix Proxying when StartAdminInterface=true (#778)
* ProxyHelper fixes * . * more reformat * .
- Loading branch information
Showing
39 changed files
with
1,880 additions
and
1,825 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,25 +1,24 @@ | ||
using System; | ||
|
||
namespace WireMock.Models | ||
namespace WireMock.Models; | ||
|
||
/// <summary> | ||
/// TimeSettings: Start, End and TTL | ||
/// </summary> | ||
public interface ITimeSettings | ||
{ | ||
/// <summary> | ||
/// TimeSettings: Start, End and TTL | ||
/// Gets or sets the DateTime from which this mapping should be used. In case this is not defined, it's used (default behavior). | ||
/// </summary> | ||
public interface ITimeSettings | ||
{ | ||
/// <summary> | ||
/// Gets or sets the DateTime from which this mapping should be used. In case this is not defined, it's used (default behavior). | ||
/// </summary> | ||
DateTime? Start { get; set; } | ||
DateTime? Start { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the DateTime from until this mapping should be used. In case this is not defined, it's used forever (default behavior). | ||
/// </summary> | ||
DateTime? End { get; set; } | ||
/// <summary> | ||
/// Gets or sets the DateTime from until this mapping should be used. In case this is not defined, it's used forever (default behavior). | ||
/// </summary> | ||
DateTime? End { get; set; } | ||
|
||
/// <summary> | ||
/// Gets or sets the TTL (Time To Live) in seconds for this mapping. In case this is not defined, it's used (default behavior). | ||
/// </summary> | ||
int? TTL { get; set; } | ||
} | ||
/// <summary> | ||
/// Gets or sets the TTL (Time To Live) in seconds for this mapping. In case this is not defined, it's used (default behavior). | ||
/// </summary> | ||
int? TTL { 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,35 +1,34 @@ | ||
using System; | ||
using JetBrains.Annotations; | ||
using WireMock.Models; | ||
|
||
namespace WireMock.Extensions | ||
namespace WireMock.Extensions; | ||
|
||
internal static class TimeSettingsExtensions | ||
{ | ||
internal static class TimeSettingsExtensions | ||
public static bool IsValid(this ITimeSettings? settings) | ||
{ | ||
public static bool IsValid([CanBeNull] this ITimeSettings settings) | ||
if (settings == null) | ||
{ | ||
if (settings == null) | ||
{ | ||
return true; | ||
} | ||
return true; | ||
} | ||
|
||
var now = DateTime.Now; | ||
var start = settings.Start != null ? settings.Start.Value : now; | ||
DateTime end; | ||
if (settings.End != null) | ||
{ | ||
end = settings.End.Value; | ||
} | ||
else if (settings.TTL != null) | ||
{ | ||
end = start.AddSeconds(settings.TTL.Value); | ||
} | ||
else | ||
{ | ||
end = DateTime.MaxValue; | ||
} | ||
var now = DateTime.Now; | ||
var start = settings.Start ?? now; | ||
DateTime end; | ||
|
||
return now >= start && now <= end; | ||
if (settings.End != null) | ||
{ | ||
end = settings.End.Value; | ||
} | ||
else if (settings.TTL != null) | ||
{ | ||
end = start.AddSeconds(settings.TTL.Value); | ||
} | ||
else | ||
{ | ||
end = DateTime.MaxValue; | ||
} | ||
|
||
return now >= start && now <= end; | ||
} | ||
} |
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.