Implemented GET /v2/LogFile
This commit is contained in:
parent
cce4901a5d
commit
64482931a3
@ -217,7 +217,7 @@ public partial class Server : GlobalBase, IDisposable
|
|||||||
case "jpeg":
|
case "jpeg":
|
||||||
response.ContentType = "image/jpeg";
|
response.ContentType = "image/jpeg";
|
||||||
break;
|
break;
|
||||||
case "log":
|
default:
|
||||||
response.ContentType = "text/plain";
|
response.ContentType = "text/plain";
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -7,7 +7,18 @@ public partial class Server
|
|||||||
{
|
{
|
||||||
private ValueTuple<HttpStatusCode, object?> GetV2LogFile(GroupCollection groups, Dictionary<string, string> requestParameters)
|
private ValueTuple<HttpStatusCode, object?> GetV2LogFile(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||||
{
|
{
|
||||||
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotImplemented, "Not Implemented");
|
if (logger is null || !File.Exists(logger?.logFilePath))
|
||||||
|
{
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.NotFound, "Missing Logfile");
|
||||||
|
}
|
||||||
|
|
||||||
|
FileStream logFile = new (logger.logFilePath, FileMode.Open, FileAccess.Read);
|
||||||
|
FileStream content = new(Path.GetTempFileName(), FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.ReadWrite, 0, FileOptions.DeleteOnClose);
|
||||||
|
logFile.Position = 0;
|
||||||
|
logFile.CopyTo(content);
|
||||||
|
content.Position = 0;
|
||||||
|
logFile.Dispose();
|
||||||
|
return new ValueTuple<HttpStatusCode, object?>(HttpStatusCode.OK, content);
|
||||||
}
|
}
|
||||||
|
|
||||||
private ValueTuple<HttpStatusCode, object?> GetV2Ping(GroupCollection groups, Dictionary<string, string> requestParameters)
|
private ValueTuple<HttpStatusCode, object?> GetV2Ping(GroupCollection groups, Dictionary<string, string> requestParameters)
|
||||||
|
@ -878,6 +878,10 @@ Returns the current log-file.
|
|||||||
<summary>Returns</summary>
|
<summary>Returns</summary>
|
||||||
|
|
||||||
The Logfile as Stream.
|
The Logfile as Stream.
|
||||||
|
|
||||||
|
| StatusCode | Meaning |
|
||||||
|
|------------|------------|
|
||||||
|
| 404 | No Logfile |
|
||||||
</details>
|
</details>
|
||||||
|
|
||||||
### <sub>![GET](https://img.shields.io/badge/GET-0f0)</sub> `/v2/Ping`
|
### <sub>![GET](https://img.shields.io/badge/GET-0f0)</sub> `/v2/Ping`
|
||||||
|
Loading…
Reference in New Issue
Block a user