{"action":"created","issue":{"url":"https://api.github.com/repos/ballerina-lang/ballerina/issues/4587","repository_url":"https://api.github.com/repos/ballerina-lang/ballerina","labels_url":"https://api.github.com/repos/ballerina-lang/ballerina/issues/4587/labels{/name}","comments_url":"https://api.github.com/repos/ballerina-lang/ballerina/issues/4587/comments","events_url":"https://api.github.com/repos/ballerina-lang/ballerina/issues/4587/events","html_url":"https://github.com/ballerina-lang/ballerina/pull/4587","id":295060323,"number":4587,"title":"[HTTP] Matrix Parameter Support","user":{"login":"irunika","id":9251082,"avatar_url":"https://avatars3.githubusercontent.com/u/9251082?v=4","gravatar_id":"","url":"https://api.github.com/users/irunika","html_url":"https://github.com/irunika","followers_url":"https://api.github.com/users/irunika/followers","following_url":"https://api.github.com/users/irunika/following{/other_user}","gists_url":"https://api.github.com/users/irunika/gists{/gist_id}","starred_url":"https://api.github.com/users/irunika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irunika/subscriptions","organizations_url":"https://api.github.com/users/irunika/orgs","repos_url":"https://api.github.com/users/irunika/repos","events_url":"https://api.github.com/users/irunika/events{/privacy}","received_events_url":"https://api.github.com/users/irunika/received_events","type":"User","site_admin":false},"labels":[{"id":830057046,"url":"https://api.github.com/repos/ballerina-lang/ballerina/labels/component/stdlib","name":"component/stdlib","color":"c5def5","default":false}],"state":"closed","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":1,"created_at":"2018-02-07T09:17:39Z","updated_at":"2018-02-08T13:14:57Z","closed_at":"2018-02-08T09:58:20Z","author_association":"CONTRIBUTOR","pull_request":{"url":"https://api.github.com/repos/ballerina-lang/ballerina/pulls/4587","html_url":"https://github.com/ballerina-lang/ballerina/pull/4587","diff_url":"https://github.com/ballerina-lang/ballerina/pull/4587.diff","patch_url":"https://github.com/ballerina-lang/ballerina/pull/4587.patch"},"body":"## Purpose\r\nIn current ballerina HTTP module, there is no way to extract matrix parameters from the URI. This is the implementation of matrix parameter extraction from the URI.\r\n\r\nThis resolves https://github.com/ballerina-lang/ballerina/issues/3997\r\n\r\n## Goals\r\nExtract matrix parameters from the URI and create a valid URI for path parameters.\r\n\r\n## Automation tests\r\n - Unit tests \r\n>yes\r\n - Integration tests\r\n>N/A\r\n\r\n## Security checks\r\n - Followed secure coding standards in http://wso2.com/technical-reports/wso2-secure-engineering-guidelines? yes\r\n - Ran FindSecurityBugs plugin and verified report? no\r\n - Confirmed that this PR doesn't commit any keys, passwords, tokens, usernames, or other secrets? yes\r\n\r\n## Samples\r\n```ballerina\r\nimport ballerina.net.http;\r\n\r\n@http:configuration {basePath:\"/hello\"}\r\nservice<http> testService {\r\n\r\n    @http:resourceConfig {\r\n        methods:[\"GET\"],\r\n        path:\"/{person}/{year}/foo\"\r\n    }\r\n    resource test1 (http:Connection conn, http:InRequest req, string person, string year) {\r\n        http:OutResponse res = {};\r\n        json outJson = {};\r\n        outJson.pathParams = string `{{person}}, {{year}}`;\r\n\r\n        map personMParams = req.getMatrixParams(string `/hello/{{person}}`);\r\n        var age, _ = (string) personMParams[\"age\"];\r\n        var color, _ = (string) personMParams[\"color\"];\r\n        outJson.personMatrix = string `age={{age}};color={{color}}`;\r\n\r\n        map yearMParams = req.getMatrixParams(string `/hello/{{person}}/{{year}}`);\r\n        var month, _ = (string) yearMParams[\"month\"];\r\n        var day, _ = (string) yearMParams[\"day\"];\r\n        outJson.yearMatrix = string `month={{month}};day={{day}}`;\r\n\r\n        map fooMParams = req.getMatrixParams(string `/hello/{{person}}/{{year}}/foo`);\r\n        var a, _ = (string) fooMParams[\"a\"];\r\n        var b, _ = (string) fooMParams[\"b\"];\r\n        outJson.fooMatrix = string `a={{a}};b={{b}}`;\r\n\r\n        map queryParams = req.getQueryParams();\r\n        var x, _ = (string) queryParams[\"x\"];\r\n        var y, _ = (string) queryParams[\"y\"];\r\n        outJson.queryParams = string `x={{x}}&y={{y}}`;\r\n\r\n        res.setJsonPayload(outJson);\r\n        _ = conn.respond(res);\r\n    }\r\n}\r\n```\r\n\r\nRun the sample and connect to it using \r\nhttp://localhost:9090/hello/john;age=10;color=white/1991;month=may;day=12/foo;a=5;b=10?x=10&y=5\r\n\r\nResponse should be\r\n```json\r\n{\r\n    \"pathParams\": \"john, 1991\",\r\n    \"personMatrix\": \"age=10;color=white\",\r\n    \"yearMatrix\": \"month=may;day=12\",\r\n    \"fooMatrix\": \"a=5;b=10\",\r\n    \"queryParams\": \"x=10&y=5\"\r\n}\r\n```"},"comment":{"url":"https://api.github.com/repos/ballerina-lang/ballerina/issues/comments/364107910","html_url":"https://github.com/ballerina-lang/ballerina/pull/4587#issuecomment-364107910","issue_url":"https://api.github.com/repos/ballerina-lang/ballerina/issues/4587","id":364107910,"user":{"login":"irunika","id":9251082,"avatar_url":"https://avatars3.githubusercontent.com/u/9251082?v=4","gravatar_id":"","url":"https://api.github.com/users/irunika","html_url":"https://github.com/irunika","followers_url":"https://api.github.com/users/irunika/followers","following_url":"https://api.github.com/users/irunika/following{/other_user}","gists_url":"https://api.github.com/users/irunika/gists{/gist_id}","starred_url":"https://api.github.com/users/irunika/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/irunika/subscriptions","organizations_url":"https://api.github.com/users/irunika/orgs","repos_url":"https://api.github.com/users/irunika/repos","events_url":"https://api.github.com/users/irunika/events{/privacy}","received_events_url":"https://api.github.com/users/irunika/received_events","type":"User","site_admin":false},"created_at":"2018-02-08T13:14:57Z","updated_at":"2018-02-08T13:14:57Z","author_association":"CONTRIBUTOR","body":"@shafreenAnfar \r\nFollowings are the results of the load test that I performed. \r\n\r\n## Spec\r\nMemory: 7.5 GB\r\nprocessor: Intel® Core™ i7-5500U CPU @ 2.40GHz × 4\r\nOS: Ubuntu 16.04 LTS\r\n\r\n## Source Code\r\n```ballerina\r\nimport ballerina.net.http;\r\n\r\n@http:configuration {basePath:\"/hello\"}\r\nservice<http> testService {\r\n\r\n    @http:resourceConfig {\r\n        methods:[\"GET\"],\r\n        path:\"/{person}/{year}/foo\"\r\n    }\r\n    resource test1 (http:Connection conn, http:InRequest req, string person, string year) {\r\n        _ = conn.respond({});\r\n    }\r\n}\r\n```\r\n\r\n## URI Used\r\nhttp://localhost:9090/hello/john/1991/foo?x=4&y=6\r\n\r\n\r\n## Results\r\n### Result without matrix params\r\n![image2](https://user-images.githubusercontent.com/9251082/35974569-9aad34f6-0cff-11e8-9525-052cdf6884cb.png)\r\n\r\n### Result with matrix params\r\n![image4](https://user-images.githubusercontent.com/9251082/35974592-acafde2e-0cff-11e8-9ccb-ac281f8015c4.png)\r\n\r\n"}}
{"actor":{"display_login":"irunika"}}