aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--README.md3
-rw-r--r--http/http.go10
-rw-r--r--http/http_test.go1
3 files changed, 14 insertions, 0 deletions
diff --git a/README.md b/README.md
index 1c801e9..5f181a8 100644
--- a/README.md
+++ b/README.md
@@ -40,6 +40,9 @@ Bornyasherk
$ curl ifconfig.co/asn
AS59795
+
+$ curl ifconfig.co/asn-org
+Hosting4Real
```
As JSON:
diff --git a/http/http.go b/http/http.go
index 626d75b..d0a1838 100644
--- a/http/http.go
+++ b/http/http.go
@@ -240,6 +240,15 @@ func (s *Server) CLIASNHandler(w http.ResponseWriter, r *http.Request) *appError
return nil
}
+func (s *Server) CLIASNOrgHandler(w http.ResponseWriter, r *http.Request) *appError {
+ response, err := s.newResponse(r)
+ if err != nil {
+ return badRequest(err).WithMessage(err.Error()).AsJSON()
+ }
+ fmt.Fprintf(w, "%s\n", response.ASNOrg)
+ return nil
+}
+
func (s *Server) JSONHandler(w http.ResponseWriter, r *http.Request) *appError {
response, err := s.newResponse(r)
if err != nil {
@@ -431,6 +440,7 @@ func (s *Server) Handler() http.Handler {
r.Route("GET", "/city", s.CLICityHandler)
r.Route("GET", "/coordinates", s.CLICoordinatesHandler)
r.Route("GET", "/asn", s.CLIASNHandler)
+ r.Route("GET", "/asn-org", s.CLIASNOrgHandler)
}
// Browser
diff --git a/http/http_test.go b/http/http_test.go
index 29dcf1b..69c9e37 100644
--- a/http/http_test.go
+++ b/http/http_test.go
@@ -94,6 +94,7 @@ func TestCLIHandlers(t *testing.T) {
{s.URL + "/city", "Bornyasherk\n", 200, "", ""},
{s.URL + "/foo", "404 page not found", 404, "", ""},
{s.URL + "/asn", "AS59795\n", 200, "", ""},
+ {s.URL + "/asn-org", "Hosting4Real\n", 200, "", ""},
}
for _, tt := range tests {