mirror of
https://github.com/fosrl/badger.git
synced 2025-05-13 05:40:39 +01:00
wrap in data obj
This commit is contained in:
parent
0b49c84bb0
commit
8f3e53678e
1 changed files with 8 additions and 10 deletions
14
main.go
14
main.go
|
@ -5,7 +5,6 @@ import (
|
||||||
"context"
|
"context"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -32,8 +31,10 @@ type VerifyBody struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
type VerifyResponse struct {
|
type VerifyResponse struct {
|
||||||
|
Data struct {
|
||||||
Valid bool `json:"valid"`
|
Valid bool `json:"valid"`
|
||||||
RedirectURL *string `json:"redirectUrl"`
|
RedirectURL *string `json:"redirectUrl"`
|
||||||
|
} `json:"data"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func CreateConfig() *Config {
|
func CreateConfig() *Config {
|
||||||
|
@ -138,16 +139,13 @@ func (p *Badger) ServeHTTP(rw http.ResponseWriter, req *http.Request) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
bodyContent, err := io.ReadAll(resp.Body)
|
fmt.Println("handling response")
|
||||||
if err != nil {
|
|
||||||
http.Error(rw, "Internal Server Error", http.StatusInternalServerError)
|
if result.Valid {
|
||||||
|
p.next.ServeHTTP(rw, req)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
fmt.Println("response body:", string(bodyContent))
|
|
||||||
|
|
||||||
fmt.Println("handling response")
|
|
||||||
|
|
||||||
if result.RedirectURL != nil && *result.RedirectURL != "" {
|
if result.RedirectURL != nil && *result.RedirectURL != "" {
|
||||||
http.Redirect(rw, req, *result.RedirectURL, http.StatusFound)
|
http.Redirect(rw, req, *result.RedirectURL, http.StatusFound)
|
||||||
return
|
return
|
||||||
|
|
Loading…
Reference in a new issue