garyf / json_web_token_ex

An Elixir implementation of the JSON Web Token (JWT) Standard, RFC 7519
MIT License
143 stars 50 forks source link

Opts argument: Keyword list #13

Open theduke opened 8 years ago

theduke commented 8 years ago

The idiomatic Elixir way would be to accept a Keyword list for options, not a map.

Maybe the API can be changed to accept both for now, and eventually deprecate the map and remove support in a future major release?

I'd be happy to provide a patch.

garyf commented 8 years ago

Actually, I am inclined to go in a different direction by using a string-keyed (rather than atom) map for the options being passed by an un-trusted user.

wmnnd commented 7 years ago

@garyf Hey there, thanks for making this library!

I also noticed you’re using Maps instead of Keyword lists for the opts. I agree with @theduke that a Keyword list would be more idiomatic for Elixir. But right now, both Maps and Keywords seem to be working with this library anyways.

I was also wondering about your rationale for using a string-keyed map - would the verify/3 function not usually be called from code with trusted information? Or were you referring to the map returned by a successful verification? I think here it might make sense to have an additional option to choose between atoms and strings as keys.