Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mpolden/echoip.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md1
-rw-r--r--api/api.go14
-rw-r--r--main.go2
3 files changed, 1 insertions, 16 deletions
diff --git a/README.md b/README.md
index dae61bc..955e45e 100644
--- a/README.md
+++ b/README.md
@@ -85,7 +85,6 @@ Application Options:
-f, --country-db=FILE Path to GeoIP country database
-c, --city-db=FILE Path to GeoIP city database
-l, --listen=ADDR Listening address (default: :8080)
- -x, --cors Allow requests from other domains
-r, --reverse-lookup Perform reverse hostname lookups
-p, --port-lookup Enable port lookup
-t, --template= Path to template (default: index.html)
diff --git a/api/api.go b/api/api.go
index de75b93..e822dfc 100644
--- a/api/api.go
+++ b/api/api.go
@@ -23,7 +23,6 @@ var USER_AGENT_RE = regexp.MustCompile(
)
type API struct {
- CORS bool
Template string
oracle Oracle
ipFromRequest func(*http.Request) (net.IP, error)
@@ -190,16 +189,6 @@ func cliMatcher(r *http.Request, rm *mux.RouteMatch) bool {
return USER_AGENT_RE.MatchString(r.UserAgent())
}
-func (a *API) requestFilter(next http.Handler) http.Handler {
- return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
- if a.CORS {
- w.Header().Set("Access-Control-Allow-Methods", "GET")
- w.Header().Set("Access-Control-Allow-Origin", "*")
- }
- next.ServeHTTP(w, r)
- })
-}
-
type appHandler func(http.ResponseWriter, *http.Request) *appError
func (fn appHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
@@ -249,8 +238,7 @@ func (a *API) Handlers() http.Handler {
// Not found handler which returns JSON when appropriate
r.NotFoundHandler = appHandler(a.NotFoundHandler)
- // Pass all requests through the request filter
- return a.requestFilter(r)
+ return r
}
func (a *API) ListenAndServe(addr string) error {
diff --git a/main.go b/main.go
index 66d51ff..1e541a5 100644
--- a/main.go
+++ b/main.go
@@ -14,7 +14,6 @@ func main() {
CountryDBPath string `short:"f" long:"country-db" description:"Path to GeoIP country database" value-name:"FILE" default:""`
CityDBPath string `short:"c" long:"city-db" description:"Path to GeoIP city database" value-name:"FILE" default:""`
Listen string `short:"l" long:"listen" description:"Listening address" value-name:"ADDR" default:":8080"`
- CORS bool `short:"x" long:"cors" description:"Allow requests from other domains"`
ReverseLookup bool `short:"r" long:"reverse-lookup" description:"Perform reverse hostname lookups"`
PortLookup bool `short:"p" long:"port-lookup" description:"Enable port lookup"`
Template string `short:"t" long:"template" description:"Path to template" default:"index.html"`
@@ -47,7 +46,6 @@ func main() {
}
api := api.New(oracle)
- api.CORS = opts.CORS
api.Template = opts.Template
log.Printf("Listening on %s", opts.Listen)