lib/popcorn: generalize colors for status codes
authorAlexandre Terrasa <alexandre@moz-code.org>
Fri, 5 Aug 2016 19:30:56 +0000 (15:30 -0400)
committerAlexandre Terrasa <alexandre@moz-code.org>
Fri, 5 Aug 2016 19:30:56 +0000 (15:30 -0400)
Signed-off-by: Alexandre Terrasa <alexandre@moz-code.org>

lib/popcorn/pop_middlewares.nit

index 518d9dc..8769f75 100644 (file)
@@ -69,9 +69,11 @@ end
 redef class HttpResponse
        # Return `self` status colored for console.
        fun color_status: String do
-               if status_code == 200 then return status_code.to_s.green
-               if status_code == 304 then return status_code.to_s.blue
-               if status_code == 404 then return status_code.to_s.yellow
-               return status_code.to_s.red
+               if status_code >= 100 and status_code < 200 then return status_code.to_s.gray
+               if status_code >= 200 and status_code < 300 then return status_code.to_s.green
+               if status_code >= 300 and status_code < 400 then return status_code.to_s.blue
+               if status_code >= 400 and status_code < 500 then return status_code.to_s.yellow
+               if status_code >= 500 and status_code < 600 then return status_code.to_s.red
+               return status_code.to_s
        end
 end