diff --git a/flags/append.go b/flags/append.go index ed4b639b..3235e512 100644 --- a/flags/append.go +++ b/flags/append.go @@ -11,6 +11,8 @@ func AppendWWWFlags(fs *flag.FlagSet) error { fs.String(SERVER_URI, "http://localhost:8080", "A valid aaronland/go-http-server URI.") fs.Bool(ENABLE_WWW, false, "Enable the interactive /debug endpoint to query points and display results.") + fs.Bool(ENABLE_CORS, false, "Enable CORS headers for data-related and API handlers.") + fs.Bool(ENABLE_GZIP, false, "Enable gzip-encoding for data-related and API handlers.") fs.String(PATH_PREFIX, "", "Prepend this prefix to all assets (but not HTTP handlers). This is mostly for API Gateway integrations.") diff --git a/flags/flags.go b/flags/flags.go index da14e398..65458378 100644 --- a/flags/flags.go +++ b/flags/flags.go @@ -7,6 +7,8 @@ const PATH_PIP string = "path-pip" const PATH_DATA string = "path-data" const ENABLE_WWW string = "enable-www" +const ENABLE_CORS string = "enable-cors" +const ENABLE_GZIP string = "enable-gzip" const ENABLE_TANGRAM string = "enable-tangram" const NEXTZEN_APIKEY string = "nextzen-apikey" diff --git a/flags/validate.go b/flags/validate.go index 6ea12b26..b8ebfed1 100644 --- a/flags/validate.go +++ b/flags/validate.go @@ -20,6 +20,20 @@ func ValidateWWWFlags(fs *flag.FlagSet) error { return nil } + bool_flags := []string{ + ENABLE_CORS, + ENABLE_GZIP, + } + + for _, k := range bool_flags { + + _, err := lookup.BoolVar(fs, k) + + if err != nil { + return err + } + } + init_lat, err := lookup.Float64Var(fs, INITIAL_LATITUDE) if err != nil { diff --git a/server/app.go b/server/app.go index 7d32b79b..7e355072 100644 --- a/server/app.go +++ b/server/app.go @@ -90,6 +90,9 @@ func (server_app *HTTPServerApplication) RunWithFlagSet(ctx context.Context, fs } enable_www, _ := lookup.BoolVar(fs, www_flags.ENABLE_WWW) + enable_cors, _ := lookup.BoolVar(fs, www_flags.ENABLE_CORS) + enable_gzip, _ := lookup.BoolVar(fs, www_flags.ENABLE_GZIP) + enable_tangram, _ := lookup.BoolVar(fs, www_flags.ENABLE_TANGRAM) nextzen_apikey, _ := lookup.StringVar(fs, www_flags.NEXTZEN_APIKEY) @@ -140,9 +143,6 @@ func (server_app *HTTPServerApplication) RunWithFlagSet(ctx context.Context, fs mux.Handle(path_ping, ping_handler) - enable_cors := true - enable_gzip := true - cors_origins := []string{"*"} var cors_wrapper *cors.Cors diff --git a/static/javascript/slippymap.crosshairs.js b/static/javascript/slippymap.crosshairs.js index 20641971..76f32d0d 100644 --- a/static/javascript/slippymap.crosshairs.js +++ b/static/javascript/slippymap.crosshairs.js @@ -47,12 +47,14 @@ slippymap.crosshairs = (function(){ container_el.parentNode.insertBefore(coords, container_el.nextSibling); } + /* coords.onclick = function(){ latlon = (latlon) ? false : true; self.draw_coords(map); return; }; - + */ + var pos = map.getCenter(); var lat = pos['lat']; var lon = pos['lng']; diff --git a/static/javascript/whosonfirst.net.js b/static/javascript/whosonfirst.net.js index 04dcd5ba..0482edcb 100644 --- a/static/javascript/whosonfirst.net.js +++ b/static/javascript/whosonfirst.net.js @@ -128,6 +128,7 @@ whosonfirst.net = (function(){ } req.open("get", url, true); + // req.setRequestHeader("Accept", "application/jsonx"); req.send(); } diff --git a/static/javascript/whosonfirst.spatial.api.js b/static/javascript/whosonfirst.spatial.api.js index 3d510493..0f083ab9 100644 --- a/static/javascript/whosonfirst.spatial.api.js +++ b/static/javascript/whosonfirst.spatial.api.js @@ -49,7 +49,6 @@ whosonfirst.spatial.api = (function(){ req.open("POST", abs_url, true); - req.setRequestHeader("Content-type", "application/json"); // req.setRequestHeader("Accept", "application/geo+json"); var enc_args = JSON.stringify(args);