Moved 'sponsor' out of response into just template handling

This commit is contained in:
Thatcher Peskens 2020-12-13 14:27:19 +01:00
parent 5a32d37286
commit 22bc011be6
1 changed files with 2 additions and 2 deletions

View File

@ -54,7 +54,6 @@ type Response struct {
ASNOrg string `json:"asn_org,omitempty"`
Hostname string `json:"hostname,omitempty"`
UserAgent *useragent.UserAgent `json:"user_agent,omitempty"`
Sponsor bool `json:"sponsor"`
}
type PortResponse struct {
@ -162,7 +161,6 @@ func (s *Server) newResponse(r *http.Request) (Response, error) {
ASN: autonomousSystemNumber,
ASNOrg: asn.AutonomousSystemOrganization,
Hostname: hostname,
Sponsor: s.Sponsor,
}
s.cache.Set(ip, response)
response.UserAgent = userAgentFromRequest(r)
@ -342,6 +340,7 @@ func (s *Server) DefaultHandler(w http.ResponseWriter, r *http.Request) *appErro
BoxLonRight float64
JSON string
Port bool
Sponsor bool
}{
response,
r.Host,
@ -351,6 +350,7 @@ func (s *Server) DefaultHandler(w http.ResponseWriter, r *http.Request) *appErro
response.Longitude + 0.05,
string(json),
s.LookupPort != nil,
s.Sponsor,
}
if err := t.Execute(w, &data); err != nil {
return internalServerError(err)