From 64f1bb97d93399889a5c071a38c0ad4a61f9d0bf Mon Sep 17 00:00:00 2001 From: jonakj <jonakj@stud.ntnu.no> Date: Wed, 18 May 2022 11:59:53 +0200 Subject: [PATCH] Removed unused proxy code --- proxy/reverseProxy.go | 44 ------------------------------------------- 1 file changed, 44 deletions(-) delete mode 100644 proxy/reverseProxy.go diff --git a/proxy/reverseProxy.go b/proxy/reverseProxy.go deleted file mode 100644 index c0639ce..0000000 --- a/proxy/reverseProxy.go +++ /dev/null @@ -1,44 +0,0 @@ -package main - -import ( - "log" - "net/http" - "net/http/httputil" - "net/url" - - "github.com/gin-gonic/gin" -) - -//// Inspiration taken from: https://le-gall.bzh/post/go/a-reverse-proxy-in-go-using-gin/ - -// proxy is a reverse proxy which routes traffic to "remote" through localhost:8080 -func proxy(c *gin.Context) { - remote, err := url.Parse("http://localhost:3000") - if err != nil { - panic(err) - } - - proxy := httputil.NewSingleHostReverseProxy(remote) - - // Sets request parameters - proxy.Director = func(req *http.Request) { - req.Header = c.Request.Header - req.Host = remote.Host - req.URL.Scheme = remote.Scheme - req.URL.Host = remote.Host - req.URL.Path = c.Param("proxyPath") - } - - // Start proxy - proxy.ServeHTTP(c.Writer, c.Request) -} - -func main() { - r := gin.Default() - - // Define catch all path - r.Any("/*proxyPath", proxy) - - // Start server on port 8080 - log.Fatal(r.Run(":8080")) -} -- GitLab