in jupytertestutil/jupytertestutil.go [121:149]
func (m *mockJupyter) handleKernelspecsRequest(w http.ResponseWriter, r *http.Request, body []byte) {
if strings.HasPrefix(m.relativePath(r), "/kernelspecs") {
// Handle a resources download request
log.Printf("Service kernelspecs resources request %+v", r)
if strings.HasSuffix(r.URL.Path, "logo-svg.svg") {
w.Header().Set("Content-Type", "image/svg+xml")
w.WriteHeader(http.StatusOK)
w.Write([]byte{})
return
}
// Not a known resource
http.NotFound(w, r)
return
}
if m.relativePath(r) != "/api/kernelspecs" {
http.Error(w, fmt.Sprintf("Path not supported: %q", m.relativePath(r)), http.StatusBadRequest)
return
}
if r.Method != http.MethodGet {
http.Error(w, fmt.Sprintf("Method not supported for path %q", m.relativePath(r)), http.StatusBadRequest)
return
}
resp, err := json.Marshal(m.kernelspecs)
if err != nil {
http.Error(w, fmt.Sprintf("failed to marshal kernelspecs: %v", err), http.StatusInternalServerError)
return
}
w.Write(resp)
}