Had some time to read this. Seems good so far, and I like how you made it obvious which lines were changed. Really useful.
Package issue
sekun@pop-os:~/Projects/hweather$ stack install
Error: While constructing the build plan, the following exceptions were encountered:
In the dependencies for hweather-0.1.0.0:
servant-flatten needed, but the stack configuration has no specified version (latest matching version is 0.2)
needed since hweather is a build target.
Some different approaches to resolving this:
* Recommended action: try adding the following to your extra-deps in /home/sekun/Projects/hweather/stack.yaml:
- servant-flatten-0.2@sha256:276896f7c5cdec5b8f8493f6205fded0cc602d050b58fdb09a6d7c85c3bb0837,1234
I followed its recommendation but I’m not sure if I’m supposed to cause I don’t know what stack trickery is required since I’ve never used it before. It seems to be fine.
It works!
curl
So with this one I was kinda confused with for a bit since I wasn’t sure exactly what the curl
request would look like for PUT /api/weather/:location
. It doesn’t mention how the user could try this out, only for the GET
request.
To be more specific, I was confused with how ReqBody
translates to the actual JSON body. Servant’s docs had a User
object which I assumed that it would just be a JSON object but was confused with what the key of the JSON object would be in this case. Turns out, the entire thing was just a string! Well, figures hahah.
:<|> ReqBody '[JSON] String :> Put '[JSON] String
So turns out it was just this:
> curl -H "Content-Type: application/json" -X PUT -d '"sunny"' localhost:8888/api/weather/Paris
# "sunny"