Skip to content

Commit

Permalink
update tunnel func
Browse files Browse the repository at this point in the history
  • Loading branch information
asim committed Mar 21, 2022
1 parent cff9117 commit f2a435f
Showing 1 changed file with 3 additions and 9 deletions.
12 changes: 3 additions & 9 deletions tunnel/function/tunnel.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,9 @@ package tunnel

import (
"os"

"log"
"net/http"
"net/http/httputil"
"net/url"
)

var (
Expand All @@ -23,13 +22,8 @@ func Send(w http.ResponseWriter, r *http.Request) {
// don't forward the token
r.Header.Del("Micro-Token")

url, err := url.Parse(r.Host)
if err != nil {
http.Error(w, err.Error(), 500)
return
}

// reverse proxy the request
proxy := httputil.NewSingleHostReverseProxy(url)
log.Printf("Proxying request to: %v", r.URL.Host)
proxy := httputil.NewSingleHostReverseProxy(r.URL)
proxy.ServeHTTP(w, r)
}

0 comments on commit f2a435f

Please sign in to comment.