From 137415cb5062ae3b5ce4ba8056754c1fc4febcaf Mon Sep 17 00:00:00 2001 From: Runxi Yu Date: Sun, 23 Mar 2025 12:04:27 +0800 Subject: Separate proxy stuff --- proxy.go | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 proxy.go (limited to 'proxy.go') diff --git a/proxy.go b/proxy.go new file mode 100644 index 0000000..30fe0b8 --- /dev/null +++ b/proxy.go @@ -0,0 +1,22 @@ +package main + +import ( + "log" + "net/http" + "net/http/httputil" + "net/url" +) + +var reverseProxy *httputil.ReverseProxy + +func init() { + parsedURL, err := url.Parse(destHost) + if err != nil { + log.Fatal(err) + } + reverseProxy = httputil.NewSingleHostReverseProxy(parsedURL) +} + +func proxyRequest(writer http.ResponseWriter, request *http.Request) { + reverseProxy.ServeHTTP(writer, request) +} -- cgit v1.2.3