Skip to content

Commit

Permalink
redirects: simplify
Browse files Browse the repository at this point in the history
Signed-off-by: Sumner Evans <me@sumnerevans.com>
  • Loading branch information
sumnerevans committed May 25, 2024
1 parent c3612a3 commit a59d525
Showing 1 changed file with 3 additions and 13 deletions.
16 changes: 3 additions & 13 deletions internal/application.go
Original file line number Diff line number Diff line change
Expand Up @@ -146,19 +146,9 @@ func (a *Application) Start() {
}

// Redirect pages
redirects := map[string]string{
"/register/teacher": "/register/teacher/createaccount",
"/register/student": "/",
"/register/parent": "/",
}
for path, redirectPath := range redirects {
redirFn := func(redirectPath string) func(w http.ResponseWriter, r *http.Request) {
return func(w http.ResponseWriter, r *http.Request) {
http.Redirect(w, r, redirectPath, http.StatusTemporaryRedirect)
}
}
router.HandleFunc("GET "+path, redirFn(redirectPath))
}
router.Handle("GET /register/teacher/", http.RedirectHandler("/register/teacher/createaccount", http.StatusTemporaryRedirect))
router.Handle("GET /register/student/", http.RedirectHandler("/", http.StatusTemporaryRedirect))
router.Handle("GET /register/parent/", http.RedirectHandler("/", http.StatusTemporaryRedirect))

// Registration renderers
a.TeacherLoginRenderer = a.ServeTemplateExtra(a.Log, "teacherlogin.html", a.GetEmailLoginTemplate)
Expand Down

0 comments on commit a59d525

Please sign in to comment.