Commit 98512fe
Changed files (1)
cmd
gtwy
cmd/gtwy/main.go
@@ -10,16 +10,15 @@ import (
)
func NewProxy(from, to string) http.Handler {
- director := func(r *http.Request) {
- log.Printf("%v (from: %v to: %v)\n", r.URL, from, to)
- r.URL.Scheme = "http"
- r.Host = to
- r.URL.Host = to
- r.URL.Path = strings.TrimPrefix(r.URL.Path, strings.TrimSuffix(from, "/*"))
- r.URL.RawPath = strings.TrimPrefix(r.URL.RawPath, strings.TrimSuffix(from, "/*"))
- }
return &httputil.ReverseProxy{
- Director: director,
+ Director: func(r *http.Request) {
+ log.Printf("%v (from: %v to: %v)\n", r.URL, from, to)
+ r.URL.Scheme = "http"
+ r.Host = to
+ r.URL.Host = to
+ r.URL.Path = strings.TrimPrefix(r.URL.Path, strings.TrimSuffix(from, "/*"))
+ r.URL.RawPath = strings.TrimPrefix(r.URL.RawPath, strings.TrimSuffix(from, "/*"))
+ },
Transport: http.DefaultTransport,
FlushInterval: -1,
ErrorLog: nil,
@@ -38,7 +37,7 @@ func main() {
mux.Handle("/idp/", NewProxy("/idp", "localhost:8282"))
mux.Handle("/sp/", NewProxy("/sp", "localhost:8283"))
- srv := &http.Server{
+ log.Fatal((&http.Server{
Addr: ":8080",
Handler: mux,
ReadHeaderTimeout: 10 * time.Second,
@@ -46,6 +45,5 @@ func main() {
WriteTimeout: 2 * time.Minute,
IdleTimeout: 5 * time.Minute,
ErrorLog: log.Default(),
- }
- log.Fatal(srv.ListenAndServe())
+ }).ListenAndServe())
}