snapframework/snap-core — pull request #181 by adinapoli (2013-09-21 21:58:54+00:00)
Title: Set request params

Hello folks,

this patch was born to scratch my own itches but I do think it would be useful to have in `Snap.Test`.
I've found myself using functions like `postRaw` and `put` which are great to explicitly set the HTTP body, but they lack the ability to set the `RequestBuilder` params.
This is essential in some handlers, which we rely, for example, on params being "pulled out" from the route parsing.
Small example:

``` haskell
("/news/:id", withMethod PUT handleEditNews)

...

handleEditNews = do
id <- getParam "id"
```

Here, in my tests, I do need to call `put` but at the same time to be able to "simulate" the user passing the param `id` in. This patch allows this thanks to `setRequestParams`. What's in there:

* A new function, `setRequestParams`
* Exhaustive documentation

I've run all the tests, it doesn't break anything. I can add one test if the test coverage will degrade with the introduction of this function.

Take care folks,
Alfredo