Skip to content

Commit

Permalink
Merge branch 'main' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
nsavinda authored Jun 16, 2024
2 parents 30abb53 + d95c547 commit 009956b
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions serveIt/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ var (
HomeTemplate = template.Must(template.New("home.html").Parse(webtemplates.Home))
IndexTemplate = template.Must(template.New("index.html").Parse(webtemplates.Index))
AuthTemplate = template.Must(template.New("").Parse(webtemplates.Auth))

)

type FileInfo struct {
Expand Down Expand Up @@ -55,6 +56,7 @@ func httpRequestHandler(w http.ResponseWriter, req *http.Request) {
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}

}

func fileHandler(w http.ResponseWriter, req *http.Request) {
Expand Down Expand Up @@ -97,6 +99,7 @@ func fileHandler(w http.ResponseWriter, req *http.Request) {
}

err = IndexTemplate.ExecuteTemplate(w, "index.html", data)

if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
}
Expand Down Expand Up @@ -156,6 +159,7 @@ func passwordProtected(next http.HandlerFunc) http.HandlerFunc {
http.SetCookie(w, &http.Cookie{
Name: "password",
Value: r.FormValue("password"),

Path: "/",
MaxAge: 300, // Expires after 300 seconds
})
Expand All @@ -178,6 +182,7 @@ func servePasswordPrompt(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusInternalServerError)
}


}

func checkPassword(enteredPassword string) bool {
Expand Down

0 comments on commit 009956b

Please sign in to comment.