From bec71f1f9cdf455be917c9398bdfc9ea9ed531bc Mon Sep 17 00:00:00 2001 From: Hidetake Iwata Date: Sun, 10 Oct 2021 14:13:18 +0900 Subject: [PATCH] Fix name to consistent case --- e2e_test/e2e_test.go | 4 ++-- e2e_test/error_test.go | 4 ++-- oauth2cli.go | 8 ++++---- server.go | 8 ++++---- 4 files changed, 12 insertions(+), 12 deletions(-) diff --git a/e2e_test/e2e_test.go b/e2e_test/e2e_test.go index 0fe923e..20449e0 100644 --- a/e2e_test/e2e_test.go +++ b/e2e_test/e2e_test.go @@ -219,8 +219,8 @@ func TestSuccessRedirect(t *testing.T) { }, LocalServerReadyChan: openBrowserCh, LocalServerMiddleware: loggingMiddleware(t), - SuccessRedirectUrl: sr.URL + "/success", - FailureRedirectUrl: sr.URL + "/failure", + SuccessRedirectURL: sr.URL + "/success", + FailureRedirectURL: sr.URL + "/failure", Logf: t.Logf, } token, err := oauth2cli.GetToken(ctx, cfg) diff --git a/e2e_test/error_test.go b/e2e_test/error_test.go index 04a4ed5..b198046 100644 --- a/e2e_test/error_test.go +++ b/e2e_test/error_test.go @@ -109,8 +109,8 @@ func TestFailureRedirect(t *testing.T) { }, }, LocalServerReadyChan: openBrowserCh, - SuccessRedirectUrl: sr.URL + "/success", - FailureRedirectUrl: sr.URL + "/failure", + SuccessRedirectURL: sr.URL + "/success", + FailureRedirectURL: sr.URL + "/failure", Logf: t.Logf, } _, err := oauth2cli.GetToken(ctx, cfg) diff --git a/oauth2cli.go b/oauth2cli.go index 76a2ebb..578ecd3 100644 --- a/oauth2cli.go +++ b/oauth2cli.go @@ -90,9 +90,9 @@ type Config struct { LocalServerReadyChan chan<- string // Redirect URL upon successful login - SuccessRedirectUrl string + SuccessRedirectURL string // Redirect URL upon failed login - FailureRedirectUrl string + FailureRedirectURL string // Logger function for debug. Logf func(format string, args ...interface{}) @@ -123,8 +123,8 @@ func (c *Config) validateAndSetDefaults() error { if c.LocalServerSuccessHTML == "" { c.LocalServerSuccessHTML = DefaultLocalServerSuccessHTML } - if (c.SuccessRedirectUrl != "" && c.FailureRedirectUrl == "") || - (c.SuccessRedirectUrl == "" && c.FailureRedirectUrl != "") { + if (c.SuccessRedirectURL != "" && c.FailureRedirectURL == "") || + (c.SuccessRedirectURL == "" && c.FailureRedirectURL != "") { return fmt.Errorf("when using success and failure redirect URLs, set both URLs") } if c.Logf == nil { diff --git a/server.go b/server.go index 6559f33..3b5d23f 100644 --- a/server.go +++ b/server.go @@ -145,8 +145,8 @@ func (h *localServerHandler) handleCodeResponse(w http.ResponseWriter, r *http.R return &authorizationResponse{err: fmt.Errorf("state does not match (wants %s but got %s)", h.config.State, state)} } - if h.config.SuccessRedirectUrl != "" { - http.Redirect(w, r, h.config.SuccessRedirectUrl, http.StatusFound) + if h.config.SuccessRedirectURL != "" { + http.Redirect(w, r, h.config.SuccessRedirectURL, http.StatusFound) } else { w.Header().Add("Content-Type", "text/html") if _, err := fmt.Fprintf(w, h.config.LocalServerSuccessHTML); err != nil { @@ -167,8 +167,8 @@ func (h *localServerHandler) handleErrorResponse(w http.ResponseWriter, r *http. } func (h *localServerHandler) authorizationError(w http.ResponseWriter, r *http.Request) { - if h.config.FailureRedirectUrl != "" { - http.Redirect(w, r, h.config.FailureRedirectUrl, http.StatusFound) + if h.config.FailureRedirectURL != "" { + http.Redirect(w, r, h.config.FailureRedirectURL, http.StatusFound) } else { http.Error(w, "authorization error", 500) }