Browse Source

cleaning up logging

main
Stephanie Gredell 6 months ago
parent
commit
2e9673059d
  1. 4
      handlers/auth.go
  2. 3
      handlers/welcome.go

4
handlers/auth.go

@ -24,8 +24,6 @@ func (h *Handler) Callback(w http.ResponseWriter, r *http.Request) {
http.Error(w, err.Error(), http.StatusBadRequest) http.Error(w, err.Error(), http.StatusBadRequest)
return return
} }
fmt.Println("Call back happened")
fmt.Println("we are creating the user store")
key := os.Getenv("SESSION_SECRET") // Replace with your SESSION_SECRET or similar key := os.Getenv("SESSION_SECRET") // Replace with your SESSION_SECRET or similar
maxAge := 86400 * 30 // 30 days maxAge := 86400 * 30 // 30 days
isProd := false // Set to true when serving over https isProd := false // Set to true when serving over https
@ -41,13 +39,11 @@ func (h *Handler) Callback(w http.ResponseWriter, r *http.Request) {
session.Values["user_name"] = user.Name session.Values["user_name"] = user.Name
session.Values["avatar_url"] = user.AvatarURL session.Values["avatar_url"] = user.AvatarURL
fmt.Println("we are saving the session")
err = session.Save(r, w) err = session.Save(r, w)
if err != nil { if err != nil {
fmt.Printf("error saving the session: %v", err) fmt.Printf("error saving the session: %v", err)
} }
fmt.Println("we are about to redirect")
http.Redirect(w, r, "/welcome", http.StatusFound) http.Redirect(w, r, "/welcome", http.StatusFound)
} }

3
handlers/welcome.go

@ -1,13 +1,10 @@
package handlers package handlers
import ( import (
"fmt"
"net/http" "net/http"
) )
func (h *Handler) Welcome(w http.ResponseWriter, r *http.Request) { func (h *Handler) Welcome(w http.ResponseWriter, r *http.Request) {
fmt.Printf("we have reached the welcome route")
err := h.Template.ExecuteTemplate(w, "welcome.html", nil) err := h.Template.ExecuteTemplate(w, "welcome.html", nil)
if err != nil { if err != nil {
http.Error(w, "Template rendering error", http.StatusInternalServerError) http.Error(w, "Template rendering error", http.StatusInternalServerError)

Loading…
Cancel
Save