haskell - How can I log an entire HTTP request in WAI/scotty? -
i run middleware logstdoutdev network.wai.middleware.requestlogger, logs path , accept header (possibly other headers too). want see body of post , put requests well. body happens json, printing stdout fine.
i have searched wai middleware logs have not found any. don't know enough wai internals write extracts post body , puts in myself, hoping avoid learning curve right now.
wai middleware transformation on application:
type middleware = application -> application and application handler:
type application = request -> (response -> io responsereceived) -> io responsereceived all need define handler log whatever want , delegate "real work" downstream:
-- note equivalent application -> application logallmiddleware :: application -> request -> (response -> io responsereceived) -> io responsereceived logallmiddleware app req respond = print . unpack . requestbody req app req respond please keep in mind wrote code without access ghc. may not correct.
Comments
Post a Comment