mirror of
https://github.com/wiremock/WireMock.Net.git
synced 2026-03-31 06:33:25 +02:00
DELETE /__admin/mappings
This commit is contained in:
@@ -32,6 +32,7 @@ namespace WireMock.Server
|
|||||||
// __admin/mappings
|
// __admin/mappings
|
||||||
Given(Request.Create().WithPath(AdminMappings).UsingGet()).RespondWith(new DynamicResponseProvider(MappingsGet));
|
Given(Request.Create().WithPath(AdminMappings).UsingGet()).RespondWith(new DynamicResponseProvider(MappingsGet));
|
||||||
Given(Request.Create().WithPath(AdminMappings).UsingPost()).RespondWith(new DynamicResponseProvider(MappingsPost));
|
Given(Request.Create().WithPath(AdminMappings).UsingPost()).RespondWith(new DynamicResponseProvider(MappingsPost));
|
||||||
|
Given(Request.Create().WithPath(AdminMappings).UsingDelete()).RespondWith(new DynamicResponseProvider(MappingsDelete));
|
||||||
|
|
||||||
// __admin/mappings/{guid}
|
// __admin/mappings/{guid}
|
||||||
Given(Request.Create().WithPath(_guidPathMatcher).UsingGet()).RespondWith(new DynamicResponseProvider(MappingGet));
|
Given(Request.Create().WithPath(_guidPathMatcher).UsingGet()).RespondWith(new DynamicResponseProvider(MappingGet));
|
||||||
@@ -111,6 +112,13 @@ namespace WireMock.Server
|
|||||||
return new ResponseMessage { Body = "Mapping added" };
|
return new ResponseMessage { Body = "Mapping added" };
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private ResponseMessage MappingsDelete(RequestMessage requestMessage)
|
||||||
|
{
|
||||||
|
ResetMappings();
|
||||||
|
|
||||||
|
return new ResponseMessage { Body = "Mappings deleted" };
|
||||||
|
}
|
||||||
|
|
||||||
private IRequestBuilder InitRequestBuilder(MappingModel mappingModel)
|
private IRequestBuilder InitRequestBuilder(MappingModel mappingModel)
|
||||||
{
|
{
|
||||||
IRequestBuilder requestBuilder = Request.Create();
|
IRequestBuilder requestBuilder = Request.Create();
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ namespace WireMock.Server
|
|||||||
{
|
{
|
||||||
private readonly TinyHttpServer _httpServer;
|
private readonly TinyHttpServer _httpServer;
|
||||||
|
|
||||||
private readonly IList<Mapping> _mappings = new List<Mapping>();
|
private IList<Mapping> _mappings = new List<Mapping>();
|
||||||
|
|
||||||
private readonly IList<LogEntry> _logEntries = new List<LogEntry>();
|
private readonly IList<LogEntry> _logEntries = new List<LogEntry>();
|
||||||
|
|
||||||
@@ -130,9 +130,17 @@ namespace WireMock.Server
|
|||||||
_logEntries.Clear();
|
_logEntries.Clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ResetMappings();
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Resets the mappings.
|
||||||
|
/// </summary>
|
||||||
|
public void ResetMappings()
|
||||||
|
{
|
||||||
lock (((ICollection)_mappings).SyncRoot)
|
lock (((ICollection)_mappings).SyncRoot)
|
||||||
{
|
{
|
||||||
_mappings.Clear();
|
_mappings = _mappings.Where(m => m.Provider is DynamicResponseProvider).ToList();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user