Why match request parameter using strings?

The params map (which is the second parameter there) maps strings to values, all of this coming from the user (via the http request). The conn struct contains information related to the connection and uses atoms for its keys since it is defined and populated in the server (as opposed to reflecting data from the user).

Of course, params could convert the strings to atoms, but as atoms are constants which are not garbage collected (they are intended to be used as identifiers, not as a general purpose data type), it would be possible for a user to DOS a Phoenix application just by sending lots and lots of unique keys via http requests.

(It’s also almost certainly more performant to use strings due to how substring sharing is done with bitstrings in the BEAM ..)

tl;dr → Te params map is keyed by strings because it is data that comes from the user, and the conn struct is an internal datatype with a static shape and so happily uses atoms.

HTH. :slight_smile: