Created
January 4, 2019 19:18
-
-
Save omgjlk/bc28b918a8a8072c9bcd625ff701dce7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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