luckyframework / lucky

A full-featured Crystal web framework that catches bugs for you, runs incredibly fast, and helps you write code that lasts.
https://luckyframework.org
MIT License
2.59k stars 156 forks source link

ApiClient doesn't return custom headers #1805

Closed jwoertink closed 1 year ago

jwoertink commented 1 year ago

If you have an action that sets a custom header, then you want to test that the header is returned, the ApiClient doesn't seem to have those.

I'm not totally sure, but maybe because it rebuilds a new response object?

https://github.com/luckyframework/lucky/blob/22fcb187c2045a36823a03310d1ed68aec5d8f0b/src/lucky/base_http_client.cr#L149

class SomeAction < ApiAction
  get "/foo" do
    response.headers["X-TEST"] = "test"
    json({response: "ok"})
  end
end

client = ApiClient.new
response = client.exec(SomeAction)
response.headers["X-TEST"] # does not exist
jwoertink commented 1 year ago

ugh... ok, this was just my bad. Something I was doing in my app...