Skip to content

Instantly share code, notes, and snippets.

@omgjlk
Created January 4, 2019 19:18
Show Gist options
  • Save omgjlk/bc28b918a8a8072c9bcd625ff701dce7 to your computer and use it in GitHub Desktop.
Save omgjlk/bc28b918a8a8072c9bcd625ff701dce7 to your computer and use it in GitHub Desktop.
// Perform snapshot of domain console
func DomainVNCSnapshot(w http.ResponseWriter, r *http.Request) {
ruuid := chi.URLParam(r, "uuid")
errstr := "Failure retrieving VM details"
domobj, err := GetDomObj(ruuid)
if err != nil {
http.Error(w, errstr, http.StatusInternalServerError)
return
}
defer domobj.Free()
// A screenshot is streamed so set up a non-blocking stream to receive it
st, err := conn.NewStream(1)
if err != nil {
http.Error(w, "Error setting up image stream", http.StatusInternalServerError)
return
}
defer st.Free()
mime, err := domobj.Screenshot(st, 0, 0)
if err != nil {
http.Error(w, "Error taking screenshot", http.StatusInternalServerError)
return
}
// Do something with the stream
// Determine mime type to return
// return the data
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment