(rw http.ResponseWriter, req *http.Request, dr *camtypes.Discovery)
| 277 | } |
| 278 | |
| 279 | func discoveryHelper(rw http.ResponseWriter, req *http.Request, dr *camtypes.Discovery) { |
| 280 | rw.Header().Set("Content-Type", "text/javascript") |
| 281 | if cb := req.FormValue("cb"); identOrDotPattern.MatchString(cb) { |
| 282 | fmt.Fprintf(rw, "%s(", cb) |
| 283 | defer rw.Write([]byte(");\n")) |
| 284 | } else if v := req.FormValue("var"); identOrDotPattern.MatchString(v) { |
| 285 | fmt.Fprintf(rw, "%s = ", v) |
| 286 | defer rw.Write([]byte(";\n")) |
| 287 | } |
| 288 | bytes, err := json.MarshalIndent(dr, "", " ") |
| 289 | if err != nil { |
| 290 | httputil.ServeJSONError(rw, httputil.ServerError("encoding discovery information: "+err.Error())) |
| 291 | return |
| 292 | } |
| 293 | rw.Write(bytes) |
| 294 | } |
no test coverage detected