1
0
Fork 0
mirror of https://github.com/miniflux/v2.git synced 2025-09-15 18:57:04 +00:00

refactor(proxy): remove usage of fmt

There is no need to use the heavy machinery (fmt) when we can simply use
string concatenation instead.
This commit is contained in:
jvoisin 2025-08-25 21:20:40 +02:00 committed by Frédéric Guillot
parent e8f5c2446c
commit 69aed6a332

View file

@ -8,11 +8,11 @@ import (
"crypto/sha256" "crypto/sha256"
"encoding/base64" "encoding/base64"
"errors" "errors"
"fmt"
"log/slog" "log/slog"
"net/http" "net/http"
"net/url" "net/url"
"path" "path"
"strconv"
"time" "time"
"miniflux.app/v2/internal/config" "miniflux.app/v2/internal/config"
@ -128,7 +128,7 @@ func (h *handler) mediaProxy(w http.ResponseWriter, r *http.Request) {
) )
// Forward the status code from the origin. // Forward the status code from the origin.
http.Error(w, fmt.Sprintf("Origin status code is %d", resp.StatusCode), resp.StatusCode) http.Error(w, "Origin status code is "+strconv.Itoa(resp.StatusCode), resp.StatusCode)
return return
} }
@ -140,7 +140,7 @@ func (h *handler) mediaProxy(w http.ResponseWriter, r *http.Request) {
b.WithHeader("Content-Type", resp.Header.Get("Content-Type")) b.WithHeader("Content-Type", resp.Header.Get("Content-Type"))
if filename := path.Base(parsedMediaURL.Path); filename != "" { if filename := path.Base(parsedMediaURL.Path); filename != "" {
b.WithHeader("Content-Disposition", fmt.Sprintf(`inline; filename="%s"`, filename)) b.WithHeader("Content-Disposition", `inline; filename="`+filename+`"`)
} }
forwardedResponseHeader := [...]string{"Content-Encoding", "Content-Type", "Content-Length", "Accept-Ranges", "Content-Range"} forwardedResponseHeader := [...]string{"Content-Encoding", "Content-Type", "Content-Length", "Accept-Ranges", "Content-Range"}