I'm trying to 'join' two wai Application
s together. Essentially the first app will either serve a 404 Not found response or a response that is not a 404 Not found response. I'd like to add a second application that will attempt to process the request if the first case (first application returns a 404) is present.
However looking at the type of Application
:
type Application = Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived
It's not clear how to inspect the response? As wouldn't I just end up with ResponseRecived
as the end result - which does not seem to contain any response code. As seen below:
xyzMiddle :: (Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived) ->
(Request -> (Response -> IO ResponseReceived) -> IO ResponseReceived)
xyzMiddle app req respond = do
zzz <- (app req respond)
pure zzz
How could I implement this? And or, what am I failing to understand in the above?