(w http.ResponseWriter, code int, err interface{})
| 10 | ) |
| 11 | |
| 12 | func jsonResponse(w http.ResponseWriter, code int, err interface{}) { |
| 13 | w.Header().Set("Content-Type", contentTypeJSON) |
| 14 | w.WriteHeader(code) |
| 15 | w.Write([]byte(`{"error": `)) |
| 16 | var s string |
| 17 | switch err := err.(type) { |
| 18 | case string: |
| 19 | s = err |
| 20 | case error: |
| 21 | s = err.Error() |
| 22 | default: |
| 23 | s = fmt.Sprint(err) |
| 24 | } |
| 25 | data, _ := json.Marshal(s) |
| 26 | w.Write(data) |
| 27 | w.Write([]byte(`}`)) |
| 28 | } |
| 29 | |
| 30 | func HandleForRequest(h *graph.Handle, wtyp string, wopt graph.Options, r *http.Request) (*graph.Handle, error) { |
| 31 | g, ok := h.QuadStore.(httpgraph.QuadStore) |
no test coverage detected