{"action":"created","issue":{"url":"https://api.github.com/repos/perwendel/spark/issues/339","labels_url":"https://api.github.com/repos/perwendel/spark/issues/339/labels{/name}","comments_url":"https://api.github.com/repos/perwendel/spark/issues/339/comments","events_url":"https://api.github.com/repos/perwendel/spark/issues/339/events","html_url":"https://github.com/perwendel/spark/issues/339","id":103719717,"number":339,"title":"req.params().get(\"n\") does not return a value while `req.params(\"n\") does","user":{"login":"bentolor","id":588260,"avatar_url":"https://avatars.githubusercontent.com/u/588260?v=3","gravatar_id":"","url":"https://api.github.com/users/bentolor","html_url":"https://github.com/bentolor","followers_url":"https://api.github.com/users/bentolor/followers","following_url":"https://api.github.com/users/bentolor/following{/other_user}","gists_url":"https://api.github.com/users/bentolor/gists{/gist_id}","starred_url":"https://api.github.com/users/bentolor/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bentolor/subscriptions","organizations_url":"https://api.github.com/users/bentolor/orgs","repos_url":"https://api.github.com/users/bentolor/repos","events_url":"https://api.github.com/users/bentolor/events{/privacy}","received_events_url":"https://api.github.com/users/bentolor/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-08-28T13:33:10Z","updated_at":"2015-09-04T13:03:49Z","closed_at":null,"body":"Spark maintains a unquoted map of path parameter names to values. So the map returned by `req.params()` contains key/values in the form `:key,value`, while the `params(\"name\")` without the colon is happily accepted. See the implementation code below.\r\n\r\nBesides not being documented, in my humble opinion this totally works against [POLA](https://en.wikipedia.org/wiki/Principle_of_least_astonishment) and Spark should return a map with `key,value`-pairs instead of `:key,value`.\r\n\r\nThis would allow things like: \r\n\r\n     get(\"/greet/:name\", \r\n           (req,res) -> new ModelAndView(req.params(), \"greet\"), new JadeTemplateEngine())\r\n\r\nwhich currently does not work\r\n\r\n\r\nWhat is the rationale for the current `params(name)`-method to look like\r\n```\r\n    public String params(String param) {\r\n        if (param.startsWith(\":\")) {\r\n            return params.get(param.toLowerCase());\r\n        } else {\r\n            return params.get(\":\" + param.toLowerCase());\r\n        }\r\n    }\r\n```\r\n\r\ninstead of:\r\n\r\n```\r\n    public String params(String param) {\r\n            return params.get(param);\r\n    }\r\n```\r\n"},"comment":{"url":"https://api.github.com/repos/perwendel/spark/issues/comments/137730166","html_url":"https://github.com/perwendel/spark/issues/339#issuecomment-137730166","issue_url":"https://api.github.com/repos/perwendel/spark/issues/339","id":137730166,"user":{"login":"rguderlei","id":206709,"avatar_url":"https://avatars.githubusercontent.com/u/206709?v=3","gravatar_id":"","url":"https://api.github.com/users/rguderlei","html_url":"https://github.com/rguderlei","followers_url":"https://api.github.com/users/rguderlei/followers","following_url":"https://api.github.com/users/rguderlei/following{/other_user}","gists_url":"https://api.github.com/users/rguderlei/gists{/gist_id}","starred_url":"https://api.github.com/users/rguderlei/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rguderlei/subscriptions","organizations_url":"https://api.github.com/users/rguderlei/orgs","repos_url":"https://api.github.com/users/rguderlei/repos","events_url":"https://api.github.com/users/rguderlei/events{/privacy}","received_events_url":"https://api.github.com/users/rguderlei/received_events","type":"User","site_admin":false},"created_at":"2015-09-04T13:03:49Z","updated_at":"2015-09-04T13:03:49Z","body":"For me, the \":key\" thing looks like a ruby symbol. Maybe it was the intention to emulate ruby symbols? I.e. in ruby `params[:name]` and `params[\"name\"]` are equivalent, whereas `params[\":name\"]` does not make sense (and would not work in Sinatra AFAIK)."}}