From 9c0f882ba0c7f8635ff7ab8007d134f7aefd69f2 Mon Sep 17 00:00:00 2001 From: Frédéric Guillot Date: Sat, 30 Jun 2018 12:42:12 -0700 Subject: Add specific 404 and 401 error messages --- http/client/response.go | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'http') diff --git a/http/client/response.go b/http/client/response.go index f033d61..d4e3cdc 100644 --- a/http/client/response.go +++ b/http/client/response.go @@ -24,6 +24,16 @@ type Response struct { ContentLength int64 } +// IsNotFound returns true if the resource doesn't exists anymore. +func (r *Response) IsNotFound() bool { + return r.StatusCode == 404 || r.StatusCode == 410 +} + +// IsNotAuthorized returns true if the resource require authentication. +func (r *Response) IsNotAuthorized() bool { + return r.StatusCode == 401 +} + // HasServerFailure returns true if the status code represents a failure. func (r *Response) HasServerFailure() bool { return r.StatusCode >= 400 -- cgit v1.2.3