diff options
| author | Adnan Maolood <[email protected]> | 2020-10-27 14:17:14 -0400 |
|---|---|---|
| committer | Adnan Maolood <[email protected]> | 2020-10-27 14:17:14 -0400 |
| commit | 860a33f5a2e7e3610440b31e9acba4c8affb521b (patch) | |
| tree | aba3f6543dcf5c116c1a921ba9b2be8314ee0ea0 /examples | |
| parent | Add ServeFile function (diff) | |
| download | go-gemini-860a33f5a2e7e3610440b31e9acba4c8affb521b.tar.xz go-gemini-860a33f5a2e7e3610440b31e9acba4c8affb521b.zip | |
Fix examples
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/auth.go | 12 | ||||
| -rw-r--r-- | examples/client.go | 2 |
2 files changed, 7 insertions, 7 deletions
diff --git a/examples/auth.go b/examples/auth.go index bb07658..bc12258 100644 --- a/examples/auth.go +++ b/examples/auth.go @@ -76,7 +76,7 @@ func login(w *gmi.ResponseWriter, r *gmi.Request) { sessions[fingerprint] = &session{ username: username, } - gmi.Redirect(w, r, "/login/password") + gmi.Redirect(w, "/login/password") } func loginPassword(w *gmi.ResponseWriter, r *gmi.Request) { @@ -86,7 +86,7 @@ func loginPassword(w *gmi.ResponseWriter, r *gmi.Request) { } session, ok := getSession(cert) if !ok { - gmi.CertificateNotAuthorized(w, r) + w.WriteStatus(gmi.StatusCertificateNotAuthorized) return } @@ -97,7 +97,7 @@ func loginPassword(w *gmi.ResponseWriter, r *gmi.Request) { expected := logins[session.username].password if password == expected { session.authorized = true - gmi.Redirect(w, r, "/profile") + gmi.Redirect(w, "/profile") } else { gmi.SensitiveInput(w, r, "Wrong password. Try again") } @@ -120,7 +120,7 @@ func profile(w *gmi.ResponseWriter, r *gmi.Request) { } session, ok := getSession(cert) if !ok { - gmi.CertificateNotAuthorized(w, r) + w.WriteStatus(gmi.StatusCertificateNotAuthorized) return } user := logins[session.username] @@ -136,12 +136,12 @@ func admin(w *gmi.ResponseWriter, r *gmi.Request) { } session, ok := getSession(cert) if !ok { - gmi.CertificateNotAuthorized(w, r) + w.WriteStatus(gmi.StatusCertificateNotAuthorized) return } user := logins[session.username] if !user.admin { - gmi.CertificateNotAuthorized(w, r) + w.WriteStatus(gmi.StatusCertificateNotAuthorized) return } fmt.Fprintln(w, "Welcome to the admin portal.") diff --git a/examples/client.go b/examples/client.go index af94d44..659e783 100644 --- a/examples/client.go +++ b/examples/client.go @@ -73,7 +73,7 @@ func sendRequest(req *gmi.Request) error { } // TODO: More fine-grained analysis of the status code. - switch resp.Status / 10 { + switch resp.Status.Class() { case gmi.StatusClassInput: fmt.Printf("%s: ", resp.Meta) scanner.Scan() |