(w http.ResponseWriter, r *http.Request)
| 335 | } |
| 336 | |
| 337 | func handleStreamFile(w http.ResponseWriter, r *http.Request) { |
| 338 | path := r.URL.Query().Get("path") |
| 339 | if path == "" { |
| 340 | http.Error(w, "path is required", http.StatusBadRequest) |
| 341 | return |
| 342 | } |
| 343 | no404 := r.URL.Query().Get("no404") |
| 344 | // path should already be formatted as a wsh:// URI (e.g. wsh://local/path or wsh://connection/path) |
| 345 | err := handleStreamFileFromReader(w, r, path, no404 != "") |
| 346 | if err != nil { |
| 347 | log.Printf("error streaming file %q: %v\n", path, err) |
| 348 | http.Error(w, fmt.Sprintf("error streaming file: %v", err), http.StatusInternalServerError) |
| 349 | } |
| 350 | } |
| 351 | |
| 352 | func WriteJsonError(w http.ResponseWriter, errVal error) { |
| 353 | w.Header().Set(ContentTypeHeaderKey, ContentTypeJson) |
nothing calls this directly
no test coverage detected