5
0
mirror of https://github.com/wailsapp/wails.git synced 2025-05-02 22:31:06 +08:00

Use NewSingleHostReverseProxy (#3480)

This commit is contained in:
Lea Anthony 2024-05-15 05:04:28 +10:00 committed by GitHub
parent 035ede4701
commit cf18fcfc1e
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -3,12 +3,10 @@ package assetserver
import (
"errors"
"fmt"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
"net/http"
"net/http/httputil"
"net/url"
"runtime"
"github.com/wailsapp/wails/v2/pkg/options/assetserver"
)
func NewProxyServer(proxyURL string) http.Handler {
@ -16,10 +14,7 @@ func NewProxyServer(proxyURL string) http.Handler {
if err != nil {
panic(err)
}
return NewExternalAssetsHandler(nil,
assetserver.Options{},
parsedURL)
return httputil.NewSingleHostReverseProxy(parsedURL)
}
func NewExternalAssetsHandler(logger Logger, options assetserver.Options, url *url.URL) http.Handler {
@ -68,7 +63,7 @@ func NewExternalAssetsHandler(logger Logger, options assetserver.Options, url *u
var result http.Handler = http.HandlerFunc(
func(rw http.ResponseWriter, req *http.Request) {
if runtime.GOOS == "darwin" || req.Method == http.MethodGet {
if req.Method == http.MethodGet {
proxy.ServeHTTP(rw, req)
return
}