mirror of https://github.com/mpolden/echoip
Moved 'sponsor' out of response into just template handling
This commit is contained in:
parent
5a32d37286
commit
22bc011be6
|
@ -54,7 +54,6 @@ type Response struct {
|
||||||
ASNOrg string `json:"asn_org,omitempty"`
|
ASNOrg string `json:"asn_org,omitempty"`
|
||||||
Hostname string `json:"hostname,omitempty"`
|
Hostname string `json:"hostname,omitempty"`
|
||||||
UserAgent *useragent.UserAgent `json:"user_agent,omitempty"`
|
UserAgent *useragent.UserAgent `json:"user_agent,omitempty"`
|
||||||
Sponsor bool `json:"sponsor"`
|
|
||||||
}
|
}
|
||||||
|
|
||||||
type PortResponse struct {
|
type PortResponse struct {
|
||||||
|
@ -162,7 +161,6 @@ func (s *Server) newResponse(r *http.Request) (Response, error) {
|
||||||
ASN: autonomousSystemNumber,
|
ASN: autonomousSystemNumber,
|
||||||
ASNOrg: asn.AutonomousSystemOrganization,
|
ASNOrg: asn.AutonomousSystemOrganization,
|
||||||
Hostname: hostname,
|
Hostname: hostname,
|
||||||
Sponsor: s.Sponsor,
|
|
||||||
}
|
}
|
||||||
s.cache.Set(ip, response)
|
s.cache.Set(ip, response)
|
||||||
response.UserAgent = userAgentFromRequest(r)
|
response.UserAgent = userAgentFromRequest(r)
|
||||||
|
@ -342,6 +340,7 @@ func (s *Server) DefaultHandler(w http.ResponseWriter, r *http.Request) *appErro
|
||||||
BoxLonRight float64
|
BoxLonRight float64
|
||||||
JSON string
|
JSON string
|
||||||
Port bool
|
Port bool
|
||||||
|
Sponsor bool
|
||||||
}{
|
}{
|
||||||
response,
|
response,
|
||||||
r.Host,
|
r.Host,
|
||||||
|
@ -351,6 +350,7 @@ func (s *Server) DefaultHandler(w http.ResponseWriter, r *http.Request) *appErro
|
||||||
response.Longitude + 0.05,
|
response.Longitude + 0.05,
|
||||||
string(json),
|
string(json),
|
||||||
s.LookupPort != nil,
|
s.LookupPort != nil,
|
||||||
|
s.Sponsor,
|
||||||
}
|
}
|
||||||
if err := t.Execute(w, &data); err != nil {
|
if err := t.Execute(w, &data); err != nil {
|
||||||
return internalServerError(err)
|
return internalServerError(err)
|
||||||
|
|
Loading…
Reference in New Issue