From 73fa2659390ed6c73e4475222b4a9c14dc37b841 Mon Sep 17 00:00:00 2001 From: Derrick Hammer Date: Sat, 20 Jan 2024 08:06:50 -0500 Subject: [PATCH] feat: implement tusJwtResponseWriter WriteHeader --- api/middleware/s5.go | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/api/middleware/s5.go b/api/middleware/s5.go index 556979f..ee3905c 100644 --- a/api/middleware/s5.go +++ b/api/middleware/s5.go @@ -7,6 +7,7 @@ import ( "github.com/golang-jwt/jwt/v5" "go.sia.tech/jape" "net/http" + "net/url" "strings" ) @@ -115,11 +116,17 @@ func (w *tusJwtResponseWriter) WriteHeader(statusCode int) { // Check if this is the specific route and status if statusCode == http.StatusCreated { location := w.Header().Get("Location") - if location != "" { - w. - authHeader := w.Header().Get("Authorization") + authToken := parseAuthTokenHeader(w.Header()) + + if authToken != "" && location != "" { + + parsedUrl, _ := url.Parse(location) + parsedUrl.Query().Set("auth_token", authToken) + + w.Header().Set("Location", parsedUrl.String()) } } + w.ResponseWriter.WriteHeader(statusCode) }