summaryrefslogtreecommitdiffstats
path: root/main.go
diff options
context:
space:
mode:
authorAhmed AbdelHalim <[email protected]>2025-09-07 23:07:43 +0200
committerAhmed AbdelHalim <[email protected]>2025-09-07 23:21:21 +0200
commitb3afec6c0ff240c8ad93c34e713be98d25d535eb (patch)
treeeb02fca7aaa00222680d9d8cfb02147394d9445b /main.go
parent91a4985eacc25178171d2813d88df3fdfa91e188 (diff)
Add HTTPS check on the go app with warning on login screen
Diffstat (limited to 'main.go')
-rw-r--r--main.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/main.go b/main.go
index c8d9433..fdecd70 100644
--- a/main.go
+++ b/main.go
@@ -214,10 +214,12 @@ func (s *Server) handleLogin(w http.ResponseWriter, r *http.Request) {
}
}
-func (s *Server) showLoginForm(w http.ResponseWriter, _ *http.Request) {
+func (s *Server) showLoginForm(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "text/html; charset=utf-8")
+ isHTTPS := r.TLS != nil
templateData := map[string]any{
- "Error": "",
+ "Error": "",
+ "IsHTTPS": isHTTPS,
}
if err := s.templates.ExecuteTemplate(w, "login.html", templateData); err != nil {
log.Printf("Error rendering login template: %v", err)