mirror of
https://github.com/C9Glax/tranga.git
synced 2025-06-13 14:57:53 +02:00
Implemented GET /v2/LogFile
This commit is contained in:
@ -217,7 +217,7 @@ public partial class Server : GlobalBase, IDisposable
|
||||
case "jpeg":
|
||||
response.ContentType = "image/jpeg";
|
||||
break;
|
||||
case "log":
|
||||
default:
|
||||
response.ContentType = "text/plain";
|
||||
break;
|
||||
}
|
||||
|
@ -7,7 +7,18 @@ public partial class Server
|
||||
{
|
||||
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)
|
||||
|
Reference in New Issue
Block a user