on master help sign in
add mapResponseStatus
commit5c61a7a8bded79c4d4764c7890f75ca874dcbe79 authorminhui.xu <minhui.xu@i-soft.com.cn> dateFri 15 Apr 2016, 16:02 (11 years ago) parent5fea4ff
1 file changed+8
wai/Network/Wai.hs+8
wai/Network/Wai.hs+8
@@ -79,6 +79,7 @@ module Network.Wai
7979 -- ** Response modifiers
8080 , responseToStream
8181 , mapResponseHeaders
82+ , mapResponseStatus
8283 -- * Middleware composition
8384 , ifRequest
8485 , modifyResponse
@@ -239,6 +240,13 @@ mapResponseHeaders f (ResponseBuilder s h b) = ResponseBuilder s (f h) b
239240mapResponseHeaders f (ResponseStream s h b) = ResponseStream s (f h) b
240241mapResponseHeaders _ r@(ResponseRaw _ _) = r
241242
243+-- | Apply the provided function to the response status of the Response.
244+mapResponseStatus :: (H.Status -> H.Status) -> Response -> Response
245+mapResponseStatus f (ResponseFile s h b1 b2) = ResponseFile (f s) h b1 b2
246+mapResponseStatus f (ResponseBuilder s h b) = ResponseBuilder (f s) h b
247+mapResponseStatus f (ResponseStream s h b) = ResponseStream (f s) h b
248+mapResponseStatus _ r@(ResponseRaw _ _) = r
249+
242250----------------------------------------------------------------
243251
244252-- | The WAI application.