diff --git a/pkg/sync/favicon.ico b/pkg/sync/favicon.ico new file mode 100644 index 0000000..abae2ee Binary files /dev/null and b/pkg/sync/favicon.ico differ diff --git a/pkg/sync/http.go b/pkg/sync/http.go index f57c4fe..9d43fc0 100644 --- a/pkg/sync/http.go +++ b/pkg/sync/http.go @@ -1,6 +1,8 @@ package sync import ( + _ "embed" + "context" "fmt" "net" @@ -14,6 +16,13 @@ import ( "github.com/bakito/adguardhome-sync/pkg/log" ) +var ( + //go:embed index.html + index []byte + //go:embed favicon.ico + favicon []byte +) + func (w *worker) handleSync(rw http.ResponseWriter, req *http.Request) { switch req.Method { case http.MethodPost: @@ -25,7 +34,13 @@ func (w *worker) handleSync(rw http.ResponseWriter, req *http.Request) { } func (w *worker) handleRoot(rw http.ResponseWriter, _ *http.Request) { - _, _ = rw.Write([]byte("adguardhome-sync")) + rw.Header().Set("Content-Type", "text/html") + _, _ = rw.Write(index) +} + +func (w *worker) handleFavicon(rw http.ResponseWriter, _ *http.Request) { + rw.Header().Set("Content-Type", "image/x-icon") + _, _ = rw.Write(favicon) } func (w *worker) handleLogs(rw http.ResponseWriter, _ *http.Request) { @@ -78,6 +93,7 @@ func (w *worker) listenAndServe() { mux.HandleFunc("/api/v1/sync", use(w.handleSync, mw...)) mux.HandleFunc("/api/v1/logs", use(w.handleLogs, mw...)) + mux.HandleFunc("/favicon.ico", use(w.handleFavicon, mw...)) mux.HandleFunc("/", use(w.handleRoot, mw...)) go func() { diff --git a/pkg/sync/index.html b/pkg/sync/index.html new file mode 100644 index 0000000..e187c2c --- /dev/null +++ b/pkg/sync/index.html @@ -0,0 +1,45 @@ + + + AdGuardHome sync + + + + + + +
+
+

AdGuardHome sync

+
+
+
+
+ + +
+
+
+
+
+
+
+
+
+ + \ No newline at end of file