(w http.ResponseWriter, r *http.Request)
| 44 | } |
| 45 | |
| 46 | func (api *API) UnitReportAP(w http.ResponseWriter, r *http.Request) { |
| 47 | unit := Authenticate(w, r) |
| 48 | if unit == nil { |
| 49 | return |
| 50 | } |
| 51 | |
| 52 | client := clientIP(r) |
| 53 | body, err := ioutil.ReadAll(r.Body) |
| 54 | if err != nil { |
| 55 | ERROR(w, http.StatusUnprocessableEntity, ErrEmpty) |
| 56 | return |
| 57 | } |
| 58 | |
| 59 | var ap apReport |
| 60 | if err = json.Unmarshal(body, &ap); err != nil { |
| 61 | log.Warning("error while reading wifi ap from %s: %v", client, err) |
| 62 | ERROR(w, http.StatusUnprocessableEntity, ErrEmpty) |
| 63 | return |
| 64 | } |
| 65 | |
| 66 | if err := api.unitReport(client, unit, ap); err != nil { |
| 67 | log.Warning("%v", err) |
| 68 | ERROR(w, http.StatusUnprocessableEntity, ErrEmpty) |
| 69 | return |
| 70 | } |
| 71 | |
| 72 | JSON(w, http.StatusOK, map[string]interface{}{ |
| 73 | "success": true, |
| 74 | }) |
| 75 | } |
| 76 | |
| 77 | func (api *API) UnitReportMultipleAP(w http.ResponseWriter, r *http.Request) { |
| 78 | unit := Authenticate(w, r) |
nothing calls this directly
no test coverage detected