Support Screens API

This commit is contained in:
Lea Anthony
2023-02-15 18:56:52 +11:00
parent 045a830fbc
commit a5e10557c5
16 changed files with 347 additions and 119 deletions
+4 -2
View File
@@ -69,6 +69,8 @@ func (m *MessageProcessor) HandleRuntimeCall(rw http.ResponseWriter, r *http.Req
m.processLogMethod(method, rw, r, targetWindow, params)
case "contextmenu":
m.processContextMenuMethod(method, rw, r, targetWindow, params)
case "screens":
m.processScreensMethod(method, rw, r, targetWindow, params)
default:
m.httpError(rw, "Unknown runtime call: %s", object)
}
@@ -88,6 +90,7 @@ func (m *MessageProcessor) Info(message string, args ...any) {
}
func (m *MessageProcessor) json(rw http.ResponseWriter, data any) {
rw.Header().Set("Content-Type", "application/json")
// convert data to json
var jsonPayload = []byte("{}")
var err error
@@ -103,7 +106,6 @@ func (m *MessageProcessor) json(rw http.ResponseWriter, data any) {
m.Error("Unable to write json payload. Please report this to the Wails team! Error: %s", err)
return
}
rw.Header().Set("Content-Type", "application/json")
m.ok(rw)
}
@@ -114,7 +116,7 @@ func (m *MessageProcessor) text(rw http.ResponseWriter, data string) {
return
}
rw.Header().Set("Content-Type", "text/plain")
m.ok(rw)
rw.WriteHeader(http.StatusOK)
}
func (m *MessageProcessor) ok(rw http.ResponseWriter) {