Feat: location data at /v1/publicip/ip

This commit is contained in:
Quentin McGaw (desktop)
2021-09-05 22:54:10 +00:00
parent 82ac568ee3
commit f9cb71027c
9 changed files with 62 additions and 42 deletions

View File

@@ -38,14 +38,9 @@ func (h *publicIPHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) {
}
}
type publicIPWrapper struct {
PublicIP string `json:"public_ip"`
}
func (h *publicIPHandler) getPublicIP(w http.ResponseWriter) {
publicIP := h.looper.GetPublicIP()
data := h.looper.GetData()
encoder := json.NewEncoder(w)
data := publicIPWrapper{PublicIP: publicIP.String()}
if err := encoder.Encode(data); err != nil {
h.logger.Warn(err.Error())
w.WriteHeader(http.StatusInternalServerError)