(w http.ResponseWriter, r *http.Request)
| 340 | } |
| 341 | |
| 342 | func (s *Server) DefaultHandler(w http.ResponseWriter, r *http.Request) *appError { |
| 343 | response, err := s.newResponse(r) |
| 344 | if err != nil { |
| 345 | return badRequest(err).WithMessage(err.Error()) |
| 346 | } |
| 347 | t, err := template.ParseGlob(s.Template + "/*") |
| 348 | if err != nil { |
| 349 | return internalServerError(err) |
| 350 | } |
| 351 | json, err := json.MarshalIndent(response, "", " ") |
| 352 | if err != nil { |
| 353 | return internalServerError(err) |
| 354 | } |
| 355 | |
| 356 | var data = struct { |
| 357 | Response |
| 358 | Host string |
| 359 | BoxLatTop float64 |
| 360 | BoxLatBottom float64 |
| 361 | BoxLonLeft float64 |
| 362 | BoxLonRight float64 |
| 363 | JSON string |
| 364 | Port bool |
| 365 | Sponsor bool |
| 366 | ExplicitLookup bool |
| 367 | }{ |
| 368 | response, |
| 369 | r.Host, |
| 370 | response.Latitude + 0.05, |
| 371 | response.Latitude - 0.05, |
| 372 | response.Longitude - 0.05, |
| 373 | response.Longitude + 0.05, |
| 374 | string(json), |
| 375 | s.LookupPort != nil, |
| 376 | s.Sponsor, |
| 377 | r.URL.Query().Has("ip"), |
| 378 | } |
| 379 | if err := t.Execute(w, &data); err != nil { |
| 380 | return internalServerError(err) |
| 381 | } |
| 382 | return nil |
| 383 | } |
| 384 | |
| 385 | func NotFoundHandler(w http.ResponseWriter, r *http.Request) *appError { |
| 386 | err := notFound(nil).WithMessage("404 page not found") |
nothing calls this directly
no test coverage detected