Hey guys,

I've lowered the pace on the development of these features, my apologies, I
got back on track last two days, and I did some changes to what you saw on
the previous commits, specifically with the RequestBuilder.

Previously the RequestBuilder was implemented by having a State Monad with
the final Request to send to the Snap action, like so:

newtype RequestBuilder a =  RequestBuilder (State Request a) deriving Monad

This was more of an API commodity, and could be seen as optional. It was
though really difficult to add new parameters and files and modify the body
of the Request accordingly; because of this, I really relied on the
RequestBuilder to recieve all the parameters the API clients one (files and
params in general), and I hold them in a partial object that will give me
the final parameters of the Request (like a Builder in GOF).

Now RequestBuilder, is implemented like this

newtype RequestBuilder a = RequestBuilder (State RequestProduct a) deriving
Monad

data RequestProduct = RequestProduct {
  rqpParams    :: Params
, rqpFileParams :: Params
, rqpHeaders   :: Headers
, rqpIsSecured :: !Bool
} deriving (Show)

The modifiers of the RequestBuilder, modify just this partial state, and the
final Request building is done on the buildRequest function (that previously
was just being used to unwrap the final Request on the first
implementations).

I've been trying to finish part of the multipart building, but I definitely
need to call for help, suggestions and guidance to finish it. I invite you
to read the buildRequest function on line 282 of Snap.Internal.Test on my
fork of the snap-core, branch testing.

URL from github:
https://github.com/roman/snap-core/blob/testing/src/Snap/Internal/Test.hs

Right now, I'm stuck on building the final multipart request body,
specially:

- Reading the contents of the files given by the developer on the Test API
- Building Random Boundary values for the multipart request


Probably the code could be better (or faster) by using a Builder on the
multipart functions? I didn't use it given that I'm not familiar with the
API and I wanted to have something done to show.

Cheers.

Roman.-
_______________________________________________
Snap mailing list
[email protected]
http://mailman-mail5.webfaction.com/listinfo/snap

Reply via email to