aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
-rw-r--r--api/api.go11
1 files changed, 8 insertions, 3 deletions
diff --git a/api/api.go b/api/api.go
index 957651e..b909755 100644
--- a/api/api.go
+++ b/api/api.go
@@ -3,12 +3,13 @@ package api
import (
"context"
"encoding/json"
- "io"
"log/slog"
"net/http"
"os"
"strconv"
"time"
+
+ "github.com/docker/docker/pkg/stdcopy"
)
type ServerStatus struct {
@@ -68,7 +69,7 @@ func VttLogs(w http.ResponseWriter, req *http.Request) {
linesParam := req.URL.Query().Get("lines")
if linesParam != "" {
- lines_64, err := strconv.ParseUint(linesParam, 10, 64)
+ lines_64, err := strconv.ParseUint(linesParam, 10, 0)
if err != nil {
Logger.ErrorContext(req.Context(), "Invalid line count in vtt logs request", slog.Any("err", err))
http.Error(w, "Invalid line count in request", http.StatusBadRequest)
@@ -85,7 +86,11 @@ func VttLogs(w http.ResponseWriter, req *http.Request) {
}
defer logReader.Close()
- io.Copy(w, logReader)
+ if _, err = stdcopy.StdCopy(w, w, logReader); err != nil {
+ Logger.Error("Error occured while writting logs to response", slog.Any("err", err), slog.Any("request", req))
+ http.Error(w, "Error occured while writting logs", http.StatusInternalServerError)
+ return
+ }
}
func SiteOnline(w http.ResponseWriter, req *http.Request) {