From b62fecf362d09999c51b2bb7965fcbc617cf7b15 Mon Sep 17 00:00:00 2001 From: some Date: Tue, 1 Oct 2024 22:11:35 -0400 Subject: [PATCH] Use errRes status instead of res --- server/callback.go | 5 ----- server/server.go | 8 +------- server/token.go | 5 ----- 3 files changed, 1 insertion(+), 17 deletions(-) diff --git a/server/callback.go b/server/callback.go index 8aead36..c600201 100644 --- a/server/callback.go +++ b/server/callback.go @@ -92,14 +92,9 @@ func (cr *CallbackRequest) Parse(data *url.Values) (err error) { } type CallbackResponse struct { - Status int `json:"-"` Message string `json:"message"` } -func (cr *CallbackResponse) HttpStatus() (code int) { - return cr.Status -} - func (cr *CallbackResponse) Response() []byte { return mustMarshalJson(cr) } diff --git a/server/server.go b/server/server.go index 49d5f85..22e9ea1 100644 --- a/server/server.go +++ b/server/server.go @@ -16,7 +16,6 @@ type EmptyRequest interface { } type Response interface { - HttpStatus() int Response() []byte } @@ -71,11 +70,6 @@ func (srv *server) ServeHTTP(w http.ResponseWriter, r *http.Request) { w.Write(errRes.ErrorResponse()) srv.logger.Logf(log.LevelError, "request failed: %s", errRes.String()) } - if res.HttpStatus() >= 100 { - w.WriteHeader(res.HttpStatus()) - } else { - w.WriteHeader(http.StatusInternalServerError) - srv.logger.Logf(log.LevelError, "received invalid status from service (%d)", res.HttpStatus()) - } + w.WriteHeader(errRes.HttpStatus()) w.Write(res.Response()) } diff --git a/server/token.go b/server/token.go index d66b017..16df2f0 100644 --- a/server/token.go +++ b/server/token.go @@ -108,7 +108,6 @@ func (tr *TokenRequest) Parse(data *url.Values) (err error) { } type TokenResponse struct { - Status int `json:"-"` VerificationUri string `json:"verification_uri"` UserCode session.Code `json:"user_code"` DeviceCode session.Code `json:"device_code"` @@ -116,10 +115,6 @@ type TokenResponse struct { ExpiresIn int `json:"expires_in"` } -func (tr *TokenResponse) HttpStatus() (code int) { - return tr.Status -} - func (tr *TokenResponse) Response() []byte { return mustMarshalJson(tr) }