Daenerys is a command line application that converts static JSON documents into executable HTTP requests.
It lets you store complex API calls as simple JSON files. You might use it for functional testing of APIs or automating complex HTTP calls. It is heavily inspired by the Chrome Postman extension
ALL YOUR HTTP ARE BELONG TO JSON
Lets create a text file containing a HTTP request that we can execute.
{
"url": "http://requestb.in/p3lsnxp3",
"method": "GET",
"headers": { "Content-Type": "application/json" },
"body" : "HELLO WORLD"
}
We can now run this from the command line so:
stack build && stack exec daenerys-exe "examples/simple-get.json"
Some of the Haskell HTTP libraries can border on overly complex sometimes.
Daenerys also provides a much nicer DSL for doing HTTP requests in Haskell with minimial fuss.
exampleRequest = InternalRequest {
requestUrl = "http://requestb.in/1d1a1121"
, requestMethod = "GET"
, headers = Just $ fromList [("Content-Type", "application/json")]
, body = Just "HELLO WORLD"
}
response = runRequest exampleRequest