diff --git a/proxy/index.go b/proxy/index.go index 675bd19..59de55e 100644 --- a/proxy/index.go +++ b/proxy/index.go @@ -2,262 +2,23 @@ package proxy import ( + "html/template" "net/http" ) -func ServeIndexPage(w http.ResponseWriter, r *http.Request) { - html := ` - - - - - Secure Site Proxy - - - -
-
-

🔒 Secure Site Proxy

-

Access websites securely through encrypted proxy

-
- -
-
- -
- - -
-
-
- -
-

Security Features:

- -
- - -
- - - -` - - w.Header().Set("Content-Type", "text/html; charset=utf-8") - w.Write([]byte(html)) +type IndexHandler struct { + templates *template.Template } + +func NewIndexHandler(templates *template.Template) *IndexHandler { + return &IndexHandler{ + templates: templates, + } +} + +func (h *IndexHandler) ServeHTTP(w http.ResponseWriter, r *http.Request) { + w.Header().Set("Content-Type", "text/html; charset=utf-8") + if err := h.templates.ExecuteTemplate(w, "index.html", nil); err != nil { + http.Error(w, "Internal server error", http.StatusInternalServerError) + } +} \ No newline at end of file