purescript-hypertrout icon indicating copy to clipboard operation
purescript-hypertrout copied to clipboard

Add ReqBody and some notion of delayed IO

Open owickstrom opened this issue 8 years ago • 6 comments

As in Servant, we need some delayed IO for work that shouldn't be done until a certain route has been selected. We do not want to read the request body, just because we traverse a ReqBody in the routing type, if the embedded handler does not match the request (and possibly cause 4xx errors and whatnot!). Instead, these things should build up and only be run when necessary.

owickstrom avatar Mar 06 '17 07:03 owickstrom

I've started experimenting with this. Early stuff. :)

owickstrom avatar Mar 27 '17 18:03 owickstrom

Hi! Thanks for this awesome (family of) project! Any news about the ReqBody feature?

yanok avatar Oct 18 '17 13:10 yanok

@yanok Glad you like them. :) No, sorry, I've had no time to work on it. I did try at some point but it's a rather big and complex change. I doubt I'll have any time soon, so if you or someone else would like to pick this up that'd be great!

owickstrom avatar Oct 20 '17 06:10 owickstrom

@owickstrom I'm a bit busy right now, but I hope to return to it at some point in the (hopefully near) future. But first I'd like to discuss the desired API a bit (sorry, I might ask really stupid questions, I was ignoring the whole Web thing completely until recently).

  1. Does it make sense to be able to put ReqBody in different places in the path? If not, shouldn't we move ReqBody closer to the method selection?
  2. Does it make sense to have multiple ReqBodys?

yanok avatar Oct 24 '17 13:10 yanok

At the moment, I'm using Raw when I need to read the request body. So those parts of the API contract are not represented in the type. It sounds like this feature would give handlers access to the request body without falling back to raw middleware? I'm not an advanced user of PureScript's type system but maybe I could help move this feature forward. Do you have a branch with your earlier work or could you say more about the approach you had in mind?

maxhallinan avatar Sep 11 '19 15:09 maxhallinan

@maxhallinan see my referenced PR for my first pass at the issue. I assume @owickstrom had something much more sophisticated in mind...

nsaunders avatar Sep 11 '19 19:09 nsaunders