about summary refs log tree commit diff
path: root/src/user.go
diff options
context:
space:
mode:
authorEmile <git@emile.space>2024-08-16 22:40:26 +0200
committerEmile <git@emile.space>2024-08-16 22:40:26 +0200
commita9930c02a33fe94141cd651212b5a815095c77ba (patch)
tree4027ea61b0cb6925604cffa56eb8a717ee3c0e0d /src/user.go
parent294659add1082f4a2333871f2a45fe0ec22fa2a7 (diff)
make template path configurable
Diffstat (limited to 'src/user.go')
-rw-r--r--src/user.go12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/user.go b/src/user.go
index 04a9fd4..f841cfa 100644
--- a/src/user.go
+++ b/src/user.go
@@ -264,7 +264,7 @@ func loginHandler(w http.ResponseWriter, r *http.Request) {
 
 		// get the template
 		log.Println("[d] Getting the template")
-		t, err := template.ParseGlob("./templates/*.html")
+		t, err := template.ParseGlob(fmt.Sprintf("%s/*.html", templatesPath))
 		if err != nil {
 			log.Println("Error parsing the login template: ", err)
 			w.WriteHeader(http.StatusInternalServerError)
@@ -342,7 +342,7 @@ func registerHandler(w http.ResponseWriter, r *http.Request) {
 		}
 
 		// get the template
-		t, err := template.ParseGlob("./templates/*.html")
+		t, err := template.ParseGlob(fmt.Sprintf("%s/*.html", templatesPath))
 		if err != nil {
 			w.WriteHeader(http.StatusInternalServerError)
 			w.Write([]byte("500 - Error reading template file"))
@@ -469,7 +469,7 @@ func userHandler(w http.ResponseWriter, r *http.Request) {
 		}
 
 		// get the template
-		t, err := template.ParseGlob("./templates/*.html")
+		t, err := template.ParseGlob(fmt.Sprintf("%s/*.html", templatesPath))
 		if err != nil {
 			w.WriteHeader(http.StatusInternalServerError)
 			w.Write([]byte("500 - Error reading template file"))
@@ -513,7 +513,7 @@ func usersHandler(w http.ResponseWriter, r *http.Request) {
 		data["users"] = users
 
 		// get the template
-		t, err := template.ParseGlob("./templates/*.html")
+		t, err := template.ParseGlob(fmt.Sprintf("%s/*.html", templatesPath))
 		if err != nil {
 			w.WriteHeader(http.StatusInternalServerError)
 			w.Write([]byte("500 - Error reading template file"))
@@ -533,7 +533,7 @@ func profileHandler(w http.ResponseWriter, r *http.Request) {
 	id, err := strconv.Atoi(vars["id"])
 	if err != nil {
 		w.WriteHeader(http.StatusInternalServerError)
-		w.Write([]byte("500 - Error reading template file"))
+		w.Write([]byte("500 - Error reading the profile id"))
 		http.Error(w, err.Error(), http.StatusInternalServerError)
 		return
 	}
@@ -589,7 +589,7 @@ func profileHandler(w http.ResponseWriter, r *http.Request) {
 		}
 
 		// get the template
-		t, err := template.ParseGlob("./templates/*.html")
+		t, err := template.ParseGlob(fmt.Sprintf("%s/*.html", templatesPath))
 		if err != nil {
 			w.WriteHeader(http.StatusInternalServerError)
 			w.Write([]byte("500 - Error reading template file"))