Use errRes status instead of res
This commit is contained in:
parent
fe10226ab2
commit
b62fecf362
@ -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)
|
||||
}
|
||||
|
@ -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())
|
||||
}
|
||||
|
@ -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)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user