soveran / cuba

Rum based microframework for web development.
http://cuba.is
MIT License
1.44k stars 249 forks source link

Proposal: remove `header` API #61

Closed larrylv closed 8 years ago

larrylv commented 9 years ago

header API was introduced in bf5f62868fc9a076358b254072af118dc909e28f, but with no examples or instructions on how to use it and also no tests of it.

Actually from the name header, we assume it's used to ensure the request has some header with it, but http header in the env hash should be start with HTTP_ prefix. So the correct implementation might be

  ENV_HTTP_HEADER_PREFIX = "HTTP_".freeze
  def header(key)
    lambda { env["#{ENV_HTTP_HEADER_PREFIX}_#{key}".upcase.tr("-","_")] }
  end

Or the user has to call header('HTTP_KEYNAME') if he/she wants to make sure the KEYNAME exist in the header.

So, as I mentioned early, since there are no examples, instructions and tests on how to use it. Should cuba just remove it?

Or if you are concerned about breaking the backward compatibility, I will be happy to contribute some docs and tests on it.

soveran commented 8 years ago

Thanks a lot for your input! It was removed in the 4.0.0 working branch.

larrylv commented 8 years ago

Glad to help. :)

moonglum commented 8 years ago

Should this be closed? :smile: