From 29628a66a68063002a19ab99cac52bbc2a98b5fd Mon Sep 17 00:00:00 2001
From: Philipp Heckel <pheckel@datto.com>
Date: Sat, 25 Dec 2021 11:56:02 +0100
Subject: [PATCH] Initial

---
 server/server.go | 9 +++++++++
 1 file changed, 9 insertions(+)

diff --git a/server/server.go b/server/server.go
index 0c0f0f0..122b2a0 100644
--- a/server/server.go
+++ b/server/server.go
@@ -253,6 +253,8 @@ func (s *Server) handleInternal(w http.ResponseWriter, r *http.Request) error {
 		return s.handleHome(w, r)
 	} else if r.Method == http.MethodGet && r.URL.Path == "/example.html" {
 		return s.handleExample(w, r)
+	} else if r.Method == http.MethodGet && r.URL.Path == "/up" {
+		return s.handleUnifiedPush(w, r)
 	} else if r.Method == http.MethodHead && r.URL.Path == "/" {
 		return s.handleEmpty(w, r)
 	} else if r.Method == http.MethodGet && staticRegex.MatchString(r.URL.Path) {
@@ -293,6 +295,13 @@ func (s *Server) handleExample(w http.ResponseWriter, _ *http.Request) error {
 	return err
 }
 
+func (s *Server) handleUnifiedPush(w http.ResponseWriter, r *http.Request) error {
+	w.Header().Set("Content-Type", "application/json")
+	w.Header().Set("Access-Control-Allow-Origin", "*") // CORS, allow cross-origin requests
+	_, err := io.WriteString(w, `{"unifiedpush":{"version":1}}`)
+	return err
+}
+
 func (s *Server) handleStatic(w http.ResponseWriter, r *http.Request) error {
 	http.FileServer(http.FS(webStaticFsCached)).ServeHTTP(w, r)
 	return nil
-- 
GitLab