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

Popular posts from this blog

linux - Does gcc have any options to add version info in ELF binary file? -

android - send complex objects as post php java -

charts - What graph/dashboard product is facebook using in Dashboard: PUE & WUE -