Răsfoiți Sursa

Added simple equality test for HttpResponse.

Rick Mann 10 ani în urmă
părinte
comite
d53764983b
1 a modificat fișierele cu 15 adăugiri și 0 ștergeri
  1. 15 0
      Common/HttpResponse.swift

+ 15 - 0
Common/HttpResponse.swift

@@ -107,3 +107,18 @@ public enum HttpResponse {
         }
     }
 }
+
+/**
+	Makes it possible to compare handler responses with '==', but
+	ignores any associated values. This should generally be what
+	you want. E.g.:
+	
+		let resp = handler(updatedRequest)
+		if resp == .NotFound {
+			print("Client requested not found: \(request.url)")
+		}
+*/
+
+func ==(inLeft: HttpResponse, inRight: HttpResponse) -> Bool {
+	return inLeft.statusCode() == inRight.statusCode()
+}