From 8f3e53678e9745831f29dc4b75f9a4ffc56c8efd Mon Sep 17 00:00:00 2001 From: Milo Schwartz Date: Sun, 24 Nov 2024 13:58:26 -0500 Subject: [PATCH] wrap in data obj --- main.go | 18 ++++++++---------- 1 file changed, 8 insertions(+), 10 deletions(-) diff --git a/main.go b/main.go index f93c333..ae09c66 100644 --- a/main.go +++ b/main.go @@ -5,7 +5,6 @@ import ( "context" "encoding/json" "fmt" - "io" "net/http" ) @@ -32,8 +31,10 @@ type VerifyBody struct { } type VerifyResponse struct { - Valid bool `json:"valid"` - RedirectURL *string `json:"redirectUrl"` + Data struct { + Valid bool `json:"valid"` + RedirectURL *string `json:"redirectUrl"` + } `json:"data"` } func CreateConfig() *Config { @@ -138,16 +139,13 @@ func (p *Badger) ServeHTTP(rw http.ResponseWriter, req *http.Request) { return } - bodyContent, err := io.ReadAll(resp.Body) - if err != nil { - http.Error(rw, "Internal Server Error", http.StatusInternalServerError) + fmt.Println("handling response") + + if result.Valid { + p.next.ServeHTTP(rw, req) return } - fmt.Println("response body:", string(bodyContent)) - - fmt.Println("handling response") - if result.RedirectURL != nil && *result.RedirectURL != "" { http.Redirect(rw, req, *result.RedirectURL, http.StatusFound) return