diff --git a/handler/routes.go b/handler/routes.go index 78193e1..89f397f 100644 --- a/handler/routes.go +++ b/handler/routes.go @@ -14,6 +14,13 @@ import ( "golang.zx2c4.com/wireguard/wgctrl/wgtypes" ) +// LoginPage handler +func LoginPage() echo.HandlerFunc { + return func(c echo.Context) error { + return c.Render(http.StatusOK, "login.html", map[string]interface{}{}) + } +} + // WireGuardClients handler func WireGuardClients() echo.HandlerFunc { return func(c echo.Context) error { diff --git a/main.go b/main.go index 972474e..f0d7f5a 100644 --- a/main.go +++ b/main.go @@ -19,6 +19,7 @@ func main() { app := router.New() app.GET("/", handler.WireGuardClients()) + app.GET("/login", handler.LoginPage()) app.POST("/new-client", handler.NewClient()) app.POST("/client/set-status", handler.SetClientStatus()) app.POST("/remove-client", handler.RemoveClient()) diff --git a/router/router.go b/router/router.go index 1260c3d..6334f7c 100644 --- a/router/router.go +++ b/router/router.go @@ -22,6 +22,10 @@ func (t *TemplateRegistry) Render(w io.Writer, name string, data interface{}, c err := errors.New("Template not found -> " + name) return err } + // login page does not need the base layout + if name == "login.html" { + return tmpl.Execute(w, data) + } return tmpl.ExecuteTemplate(w, "base.html", data) } @@ -29,6 +33,7 @@ func (t *TemplateRegistry) Render(w io.Writer, name string, data interface{}, c func New() *echo.Echo { e := echo.New() templates := make(map[string]*template.Template) + templates["login.html"] = template.Must(template.ParseFiles("templates/login.html")) templates["clients.html"] = template.Must(template.ParseFiles("templates/clients.html", "templates/base.html")) templates["server.html"] = template.Must(template.ParseFiles("templates/server.html", "templates/base.html")) templates["global_settings.html"] = template.Must(template.ParseFiles("templates/global_settings.html", "templates/base.html")) diff --git a/templates/login.html b/templates/login.html new file mode 100644 index 0000000..87278cb --- /dev/null +++ b/templates/login.html @@ -0,0 +1,79 @@ + + + + + + + WireGuard UI + + + + + + + + + + + + + + + + +
+ + +
+ + +
+
+ + + + + + + + + + +