sideshowcoder / canned

Server to respond with fake API responses, by using a directory of files for finding out what to say!
213 stars 46 forks source link

Fix variable responses for json body #42

Closed bibounde closed 9 years ago

bibounde commented 9 years ago

Canned was unable to manage variable responses when request body contains json data.

Request body

{"login":"lina.duval"}

index.post.json

//! body: {"login":"Adrien62"}
{
    "id": 42,
    "label" : "MENARD Adrien"
}
//! body: {"login":"lina.duval"}
{
    "id": 43,
    "label" : "DUVAL Lina"
}

Result is KO

{
    "id": 42,
    "label" : "MENARD Adrien"
}

I fixed the problem by parsing json data when request content type is application/json.

sideshowcoder commented 9 years ago

Awesome! Thanks for that, do you mind adding a test so we don't accidentally cause this again in the futur?

bibounde commented 9 years ago

Done ;-)

sideshowcoder commented 9 years ago

:heart: lovely!

It will be included the next time I push to NPM, probably next week :+1: Thanks so much!