feat: implement tusJwtResponseWriter WriteHeader
This commit is contained in:
parent
a56fa20b6d
commit
73fa265939
|
@ -7,6 +7,7 @@ import (
|
||||||
"github.com/golang-jwt/jwt/v5"
|
"github.com/golang-jwt/jwt/v5"
|
||||||
"go.sia.tech/jape"
|
"go.sia.tech/jape"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -115,11 +116,17 @@ func (w *tusJwtResponseWriter) WriteHeader(statusCode int) {
|
||||||
// Check if this is the specific route and status
|
// Check if this is the specific route and status
|
||||||
if statusCode == http.StatusCreated {
|
if statusCode == http.StatusCreated {
|
||||||
location := w.Header().Get("Location")
|
location := w.Header().Get("Location")
|
||||||
if location != "" {
|
authToken := parseAuthTokenHeader(w.Header())
|
||||||
w.
|
|
||||||
authHeader := w.Header().Get("Authorization")
|
if authToken != "" && location != "" {
|
||||||
|
|
||||||
|
parsedUrl, _ := url.Parse(location)
|
||||||
|
parsedUrl.Query().Set("auth_token", authToken)
|
||||||
|
|
||||||
|
w.Header().Set("Location", parsedUrl.String())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
w.ResponseWriter.WriteHeader(statusCode)
|
w.ResponseWriter.WriteHeader(statusCode)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue