func Secure(w http.ResponseWriter, r *http.Request) { _, ok := sess.Authorized(w, r) if !ok { fmt.Fprintf(w, "You are not autorized. Please visit the login page") return } fmt.Fprintf(w, "You are now viewing secure data") return }
func AdminAll(w http.ResponseWriter, r *http.Request) { role, ok := sess.Authorized(w, r) if !ok || role != "admin" { fmt.Fprintf(w, "You are not autorized as admin. Please visit the login page") return } c := sess.GetAll(r) fmt.Fprintf(w, "Session Cookies: %v", c) return }
func Admin(w http.ResponseWriter, r *http.Request) { role, ok := sess.Authorized(w, r) if !ok || role != "admin" { fmt.Printf("ROLE: %q0\n", role) fmt.Fprintf(w, "You are not autorized as admin. Please visit the login page") return } fmt.Fprintf(w, "You are now viewing admin data") return }
func SecureAll(w http.ResponseWriter, r *http.Request) { _, ok := sess.Authorized(w, r) if !ok { fmt.Fprintf(w, "You are not autorized. Please visit the login page") return } c := sess.GetAll(r) fmt.Fprintf(w, "Session Cookies: %v", c) return }
func AdminPut(w http.ResponseWriter, r *http.Request) { role, ok := sess.Authorized(w, r) if !ok || role != "admin" { fmt.Fprintf(w, "You are not autorized as admin. Please visit the login page") return } count++ key := fmt.Sprintf("KEY %d", count) val := fmt.Sprintf("VALUE %d", count) sess.Put(w, r, key, val) fmt.Fprintf(w, "Set Cookie: %s, %s", key, val) return }