Browse Source

fix indentation

master
Nicolas Massé 8 years ago
parent
commit
74e7b315b9
  1. 48
      src/itix.fr/forward/main.go

48
src/itix.fr/forward/main.go

@ -6,7 +6,7 @@ import (
"net/http/httputil"
"net/url"
"os"
"strconv"
"strconv"
)
// The MyResponseWriter is a wrapper around the standard http.ResponseWriter
@ -52,7 +52,7 @@ func SetupReverseProxy(local_port int, target string) {
// added automatically by the net/http package.
req.Host = ""
}
handler := http.NewServeMux()
handler := http.NewServeMux()
handler.HandleFunc("/", func(rw http.ResponseWriter, req *http.Request) {
// Log the incoming request (including headers)
fmt.Printf("%v %v HTTP/1.1\n", req.Method, req.URL)
@ -74,27 +74,27 @@ func SetupReverseProxy(local_port int, target string) {
})
fmt.Printf("Listening on port %v for incoming requests...\n", local_port)
err = http.ListenAndServe(fmt.Sprintf(":%v", local_port), handler)
if (err != nil) {
fmt.Println("ERROR: %s", err)
}
err = http.ListenAndServe(fmt.Sprintf(":%v", local_port), handler)
if err != nil {
fmt.Println("ERROR: %s", err)
}
}
func main() {
portal_endpoint := os.Getenv("THREESCALE_PORTAL_ENDPOINT")
backend_endpoint := os.Getenv("BACKEND_ENDPOINT_OVERRIDE")
portal_port_opt := os.Getenv("PORTAL_LISTEN_PORT")
if (portal_port_opt == "") {
portal_port_opt = "9090"
fmt.Println("WARNING: No PORTAL_LISTEN_PORT environment variable found, defaulting to '9090'...")
}
portal_port_opt := os.Getenv("PORTAL_LISTEN_PORT")
if portal_port_opt == "" {
portal_port_opt = "9090"
fmt.Println("WARNING: No PORTAL_LISTEN_PORT environment variable found, defaulting to '9090'...")
}
backend_port_opt := os.Getenv("BACKEND_LISTEN_PORT")
if (backend_port_opt == "") {
backend_port_opt = "9091"
fmt.Println("WARNING: No BACKEND_LISTEN_PORT environment variable found, defaulting to '9091'...")
}
backend_port_opt := os.Getenv("BACKEND_LISTEN_PORT")
if backend_port_opt == "" {
backend_port_opt = "9091"
fmt.Println("WARNING: No BACKEND_LISTEN_PORT environment variable found, defaulting to '9091'...")
}
error := false
if portal_endpoint == "" {
@ -105,16 +105,16 @@ func main() {
fmt.Println("ERROR: No BACKEND_ENDPOINT_OVERRIDE environment variable found !")
error = true
}
portal_port, err := strconv.Atoi(portal_port_opt)
if (err != nil) {
fmt.Printf("ERROR: Cannot parse the PORTAL_LISTEN_PORT environment variable (%s): %s\n", portal_port_opt, err)
portal_port, err := strconv.Atoi(portal_port_opt)
if err != nil {
fmt.Printf("ERROR: Cannot parse the PORTAL_LISTEN_PORT environment variable (%s): %s\n", portal_port_opt, err)
error = true
}
backend_port, err := strconv.Atoi(backend_port_opt)
if (err != nil) {
fmt.Printf("ERROR: Cannot parse the BACKEND_LISTEN_PORT environment variable (%s): %s\n", backend_port_opt, err)
}
backend_port, err := strconv.Atoi(backend_port_opt)
if err != nil {
fmt.Printf("ERROR: Cannot parse the BACKEND_LISTEN_PORT environment variable (%s): %s\n", backend_port_opt, err)
error = true
}
}
if error {
os.Exit(1)
}

Loading…
Cancel
Save