aboutsummaryrefslogtreecommitdiffhomepage
path: root/http
diff options
context:
space:
mode:
authorGravatar Frédéric Guillot <fred@miniflux.net>2018-06-30 12:42:12 -0700
committerGravatar Frédéric Guillot <fred@miniflux.net>2018-06-30 12:42:12 -0700
commit9c0f882ba0c7f8635ff7ab8007d134f7aefd69f2 (patch)
tree4056c457596aa471adcdf32cc712ca51d83eae02 /http
parenta40f592aab89cc6e5c8f2a9be8ed912f8204f070 (diff)
Add specific 404 and 401 error messages
Diffstat (limited to 'http')
-rw-r--r--http/client/response.go10
1 files changed, 10 insertions, 0 deletions
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