* Remote Api: Add flag to enable cross domain requests

This commit is contained in:
Victor Vieux
2013-06-11 10:12:36 +00:00
5 changed files with 119 additions and 10 deletions
+4 -3
View File
@@ -33,6 +33,7 @@ func main() {
bridgeName := flag.String("b", "", "Attach containers to a pre-existing network bridge")
pidfile := flag.String("p", "/var/run/docker.pid", "File containing process PID")
flHost := flag.String("H", fmt.Sprintf("%s:%d", host, port), "Host:port to bind/connect to")
flEnableCors := flag.Bool("api-enable-cors", false, "Enable CORS requests in the remote api.")
flag.Parse()
if *bridgeName != "" {
docker.NetworkBridgeIface = *bridgeName
@@ -65,7 +66,7 @@ func main() {
flag.Usage()
return
}
if err := daemon(*pidfile, host, port, *flAutoRestart); err != nil {
if err := daemon(*pidfile, host, port, *flAutoRestart, *flEnableCors); err != nil {
log.Fatal(err)
os.Exit(-1)
}
@@ -104,7 +105,7 @@ func removePidFile(pidfile string) {
}
}
func daemon(pidfile, addr string, port int, autoRestart bool) error {
func daemon(pidfile, addr string, port int, autoRestart, enableCors bool) error {
if addr != "127.0.0.1" {
log.Println("/!\\ DON'T BIND ON ANOTHER IP ADDRESS THAN 127.0.0.1 IF YOU DON'T KNOW WHAT YOU'RE DOING /!\\")
}
@@ -122,7 +123,7 @@ func daemon(pidfile, addr string, port int, autoRestart bool) error {
os.Exit(0)
}()
server, err := docker.NewServer(autoRestart)
server, err := docker.NewServer(autoRestart, enableCors)
if err != nil {
return err
}