package utils import ( // "context" "errors" // "log" "net/http" ) type UserId string func GetUserOrWriteInResponse(w http.ResponseWriter, r *http.Request) (UserId, error) { tokenStr := r.Header.Get("Authorization") if (tokenStr == "") || (len(tokenStr) < len("Bearer ")) { http.Error(w, "Unauthorized", http.StatusUnauthorized) return "", errors.New("Unauthorized") } tokenStr = tokenStr[len("Bearer "):] // token, err := verifyToken(tokenStr) // if err != nil { // log.Println(err) // http.Error(w, "Unauthorized", http.StatusUnauthorized) // return "", errors.New("Unauthorized") // } // return UserId(token.UID), nil return UserId("xxx"), nil } // func verifyToken(token string) (*auth.Token, error) { // if app == nil { // setup() // } // // client, err := app.Auth(context.Background()) // if err != nil { // log.Fatalf("error getting Auth client: %v\n", err) // } // return client.VerifyIDToken(context.Background(), token) // }