Skip to content

Commit

Permalink
proper forwarding
Browse files Browse the repository at this point in the history
  • Loading branch information
Ilya Biin committed Dec 20, 2016
1 parent 7be2752 commit 990a87a
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion cli/local2astra/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"fmt"
"os/signal"
"syscall"
"strings"
"github.com/vulcand/oxy/testutils"
)

var httpPort = flag.Int("port", 8080, "HTTP port of application to publish")
Expand Down Expand Up @@ -92,6 +94,15 @@ func main() {
forward.PassHostHeader(true),
forward.RoundTripper(transport),
)
var fwd_func = http.HandlerFunc(func(w http.ResponseWriter, req *http.Request) {
var query = req.RequestURI
if !strings.HasPrefix(query, "/") {
query = "/" + query
}
req.URL = testutils.ParseURI("http://" + req.Host + query)
req.RequestURI = query
forwarder.ServeHTTP(w, req)
})

var binder = func(ready_ch, close_ch chan bool) {
select {
Expand All @@ -100,7 +111,7 @@ func main() {
if fwdErr != nil {
log.Panicln(fwdService)
}
go http.Serve(fwdService, forwarder)
go http.Serve(fwdService, fwd_func)
defer fwdService.Close()
case <-close_ch:
case <-shutdown:
Expand Down

0 comments on commit 990a87a

Please sign in to comment.