Add support for HandleBars File (to read a file) (#278)

* HandleBarsFileFragment

* 1.0.17

* {{File}}
This commit is contained in:
Stef Heyenrath
2019-06-05 16:00:25 +02:00
committed by GitHub
parent eed73ee8b3
commit bd030594d5
13 changed files with 246 additions and 16 deletions

View File

@@ -68,6 +68,16 @@ namespace WireMock.Handlers
return File.ReadAllBytes(Path.GetFileName(path) == path ? Path.Combine(GetMappingFolder(), path) : path);
}
/// <inheritdoc cref="IFileSystemHandler.ReadResponseBodyAsString"/>
public string ReadResponseBodyAsString(string path)
{
Check.NotNullOrEmpty(path, nameof(path));
// In case the path is a filename, the path will be adjusted to the MappingFolder.
// Else the path will just be as-is.
return File.ReadAllText(Path.GetFileName(path) == path ? Path.Combine(GetMappingFolder(), path) : path);
}
/// <inheritdoc cref="IFileSystemHandler.FileExists"/>
public bool FileExists(string filename)
{