aboutsummaryrefslogtreecommitdiff
path: root/proxy.go
diff options
context:
space:
mode:
authorRunxi Yu <me@runxiyu.org>2025-03-23 12:04:27 +0800
committerRunxi Yu <me@runxiyu.org>2025-03-23 12:04:27 +0800
commit137415cb5062ae3b5ce4ba8056754c1fc4febcaf (patch)
tree95b7f7bfa04ab381e21e14a1dcd3bb1f8fc90663 /proxy.go
parentSeparate privkey stuff (diff)
downloadpowxy-137415cb5062ae3b5ce4ba8056754c1fc4febcaf.tar.gz
powxy-137415cb5062ae3b5ce4ba8056754c1fc4febcaf.tar.zst
powxy-137415cb5062ae3b5ce4ba8056754c1fc4febcaf.zip
Separate proxy stuff
Diffstat (limited to '')
-rw-r--r--proxy.go22
1 files changed, 22 insertions, 0 deletions
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)
+}