{"action":"closed","number":10,"pull_request":{"url":"https://api.github.com/repos/fiorix/go-diameter/pulls/10","id":28876131,"html_url":"https://github.com/fiorix/go-diameter/pull/10","diff_url":"https://github.com/fiorix/go-diameter/pull/10.diff","patch_url":"https://github.com/fiorix/go-diameter/pull/10.patch","issue_url":"https://api.github.com/repos/fiorix/go-diameter/issues/10","number":10,"state":"closed","locked":false,"title":"Passing custom args to HandleFunc","user":{"login":"dwilkie","id":127583,"avatar_url":"https://avatars.githubusercontent.com/u/127583?v=3","gravatar_id":"","url":"https://api.github.com/users/dwilkie","html_url":"https://github.com/dwilkie","followers_url":"https://api.github.com/users/dwilkie/followers","following_url":"https://api.github.com/users/dwilkie/following{/other_user}","gists_url":"https://api.github.com/users/dwilkie/gists{/gist_id}","starred_url":"https://api.github.com/users/dwilkie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwilkie/subscriptions","organizations_url":"https://api.github.com/users/dwilkie/orgs","repos_url":"https://api.github.com/users/dwilkie/repos","events_url":"https://api.github.com/users/dwilkie/events{/privacy}","received_events_url":"https://api.github.com/users/dwilkie/received_events","type":"User","site_admin":false},"body":"I have the following function which takes a transaction_id and msisdn and tries to create a Credit-ControlRequest:\r\n\r\n```go\r\nfunc Charge(transaction_id string, msisdn string, server_address string) (session_id string, result_code string) {\r\n\r\n  dict.Default.Load(bytes.NewReader(dict.CreditControlXML))\r\n\r\n  // ALL incoming messages are handled here.\r\n  diam.HandleFunc(\"CEA\", OnCEA) // I want to pass the transaction_id and msisdn through here\r\n  diam.HandleFunc(\"CCA\", OnCCA)\r\n  diam.HandleFunc(\"ALL\", OnMSG) // Catch-all.\r\n\r\n  var (\r\n    c   diam.Conn\r\n    err error\r\n  )\r\n  c, err = diam.Dial(server_address, nil, nil)\r\n\r\n  if err != nil {\r\n    log.Fatal(err)\r\n  }\r\n\r\n  go NewClient(c)\r\n\r\n  // Wait until the server kicks us out.\r\n\r\n  <-c.(diam.CloseNotifier).CloseNotify()\r\n  log.Println(\"Server disconnected.\")\r\n}\r\n\r\n// I want this function to accept the transaction_id and msisdn as well so I can add it to the CCR AVP\r\nfunc OnCEA(c diam.Conn, m *diam.Message) {\r\n  rc, err := m.FindAVP(avp.ResultCode)\r\n  if err != nil {\r\n    log.Fatal(err)\r\n  }\r\n  if v, _ := rc.Data.(format.Unsigned32); v != diam.Success {\r\n    log.Fatal(\"Unexpected response:\", rc)\r\n  }\r\n\r\n  // Craft a CCR message.\r\n  r := diam.NewRequest(diam.CreditControl, 4, nil)\r\n\r\n// Add AVP's containing transaction_id and msisdn\r\n}\r\n\r\nfunc OnCCA(c diam.Conn, m *diam.Message) {\r\n  // Here I want to return the result_code and session_id extracted from the AVP's\r\n}\r\n```\r\n\r\nI can't set `transaction_id` or `msisdn` to a global variable, since this will cause problems with concurrency. So the only solution I can come up with at the moment is to send both the `CER` and `CCR` in the same function and hardcoding for example `DestinationRealm` instead of using the response in the `CEA`.\r\n\r\nI looked through the RFC but I couldn't see anything in the spec for passing variables through - e.g sending `transaction_id` and `msisdn` in the `CER` and having it returned in the `CEA`.\r\n\r\nAm I missing something simple here?","created_at":"2015-02-08T05:59:26Z","updated_at":"2015-02-12T22:22:21Z","closed_at":"2015-02-12T22:22:21Z","merged_at":"2015-02-12T22:22:21Z","merge_commit_sha":"9e04dc2d2562df0e11a0946bb5786e7150506c23","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/fiorix/go-diameter/pulls/10/commits","review_comments_url":"https://api.github.com/repos/fiorix/go-diameter/pulls/10/comments","review_comment_url":"https://api.github.com/repos/fiorix/go-diameter/pulls/comments/{number}","comments_url":"https://api.github.com/repos/fiorix/go-diameter/issues/10/comments","statuses_url":"https://api.github.com/repos/fiorix/go-diameter/statuses/c0cfaaac37af04616666a4b31014d9a4a8b04479","head":{"label":"dwilkie:improve_client_example","ref":"improve_client_example","sha":"c0cfaaac37af04616666a4b31014d9a4a8b04479","user":{"login":"dwilkie","id":127583,"avatar_url":"https://avatars.githubusercontent.com/u/127583?v=3","gravatar_id":"","url":"https://api.github.com/users/dwilkie","html_url":"https://github.com/dwilkie","followers_url":"https://api.github.com/users/dwilkie/followers","following_url":"https://api.github.com/users/dwilkie/following{/other_user}","gists_url":"https://api.github.com/users/dwilkie/gists{/gist_id}","starred_url":"https://api.github.com/users/dwilkie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwilkie/subscriptions","organizations_url":"https://api.github.com/users/dwilkie/orgs","repos_url":"https://api.github.com/users/dwilkie/repos","events_url":"https://api.github.com/users/dwilkie/events{/privacy}","received_events_url":"https://api.github.com/users/dwilkie/received_events","type":"User","site_admin":false},"repo":{"id":30482188,"name":"go-diameter","full_name":"dwilkie/go-diameter","owner":{"login":"dwilkie","id":127583,"avatar_url":"https://avatars.githubusercontent.com/u/127583?v=3","gravatar_id":"","url":"https://api.github.com/users/dwilkie","html_url":"https://github.com/dwilkie","followers_url":"https://api.github.com/users/dwilkie/followers","following_url":"https://api.github.com/users/dwilkie/following{/other_user}","gists_url":"https://api.github.com/users/dwilkie/gists{/gist_id}","starred_url":"https://api.github.com/users/dwilkie/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dwilkie/subscriptions","organizations_url":"https://api.github.com/users/dwilkie/orgs","repos_url":"https://api.github.com/users/dwilkie/repos","events_url":"https://api.github.com/users/dwilkie/events{/privacy}","received_events_url":"https://api.github.com/users/dwilkie/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/dwilkie/go-diameter","description":"Diameter stack and Base Protocol for the Go programming language","fork":true,"url":"https://api.github.com/repos/dwilkie/go-diameter","forks_url":"https://api.github.com/repos/dwilkie/go-diameter/forks","keys_url":"https://api.github.com/repos/dwilkie/go-diameter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/dwilkie/go-diameter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/dwilkie/go-diameter/teams","hooks_url":"https://api.github.com/repos/dwilkie/go-diameter/hooks","issue_events_url":"https://api.github.com/repos/dwilkie/go-diameter/issues/events{/number}","events_url":"https://api.github.com/repos/dwilkie/go-diameter/events","assignees_url":"https://api.github.com/repos/dwilkie/go-diameter/assignees{/user}","branches_url":"https://api.github.com/repos/dwilkie/go-diameter/branches{/branch}","tags_url":"https://api.github.com/repos/dwilkie/go-diameter/tags","blobs_url":"https://api.github.com/repos/dwilkie/go-diameter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/dwilkie/go-diameter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/dwilkie/go-diameter/git/refs{/sha}","trees_url":"https://api.github.com/repos/dwilkie/go-diameter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/dwilkie/go-diameter/statuses/{sha}","languages_url":"https://api.github.com/repos/dwilkie/go-diameter/languages","stargazers_url":"https://api.github.com/repos/dwilkie/go-diameter/stargazers","contributors_url":"https://api.github.com/repos/dwilkie/go-diameter/contributors","subscribers_url":"https://api.github.com/repos/dwilkie/go-diameter/subscribers","subscription_url":"https://api.github.com/repos/dwilkie/go-diameter/subscription","commits_url":"https://api.github.com/repos/dwilkie/go-diameter/commits{/sha}","git_commits_url":"https://api.github.com/repos/dwilkie/go-diameter/git/commits{/sha}","comments_url":"https://api.github.com/repos/dwilkie/go-diameter/comments{/number}","issue_comment_url":"https://api.github.com/repos/dwilkie/go-diameter/issues/comments/{number}","contents_url":"https://api.github.com/repos/dwilkie/go-diameter/contents/{+path}","compare_url":"https://api.github.com/repos/dwilkie/go-diameter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/dwilkie/go-diameter/merges","archive_url":"https://api.github.com/repos/dwilkie/go-diameter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/dwilkie/go-diameter/downloads","issues_url":"https://api.github.com/repos/dwilkie/go-diameter/issues{/number}","pulls_url":"https://api.github.com/repos/dwilkie/go-diameter/pulls{/number}","milestones_url":"https://api.github.com/repos/dwilkie/go-diameter/milestones{/number}","notifications_url":"https://api.github.com/repos/dwilkie/go-diameter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/dwilkie/go-diameter/labels{/name}","releases_url":"https://api.github.com/repos/dwilkie/go-diameter/releases{/id}","created_at":"2015-02-08T05:39:37Z","updated_at":"2015-02-08T05:39:37Z","pushed_at":"2015-02-08T05:57:39Z","git_url":"git://github.com/dwilkie/go-diameter.git","ssh_url":"git@github.com:dwilkie/go-diameter.git","clone_url":"https://github.com/dwilkie/go-diameter.git","svn_url":"https://github.com/dwilkie/go-diameter","homepage":"","size":2159,"stargazers_count":0,"watchers_count":0,"language":"Go","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"fiorix:master","ref":"master","sha":"9e99e0879e92becd4828176de2477ea316f1134e","user":{"login":"fiorix","id":129742,"avatar_url":"https://avatars.githubusercontent.com/u/129742?v=3","gravatar_id":"","url":"https://api.github.com/users/fiorix","html_url":"https://github.com/fiorix","followers_url":"https://api.github.com/users/fiorix/followers","following_url":"https://api.github.com/users/fiorix/following{/other_user}","gists_url":"https://api.github.com/users/fiorix/gists{/gist_id}","starred_url":"https://api.github.com/users/fiorix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fiorix/subscriptions","organizations_url":"https://api.github.com/users/fiorix/orgs","repos_url":"https://api.github.com/users/fiorix/repos","events_url":"https://api.github.com/users/fiorix/events{/privacy}","received_events_url":"https://api.github.com/users/fiorix/received_events","type":"User","site_admin":false},"repo":{"id":12191706,"name":"go-diameter","full_name":"fiorix/go-diameter","owner":{"login":"fiorix","id":129742,"avatar_url":"https://avatars.githubusercontent.com/u/129742?v=3","gravatar_id":"","url":"https://api.github.com/users/fiorix","html_url":"https://github.com/fiorix","followers_url":"https://api.github.com/users/fiorix/followers","following_url":"https://api.github.com/users/fiorix/following{/other_user}","gists_url":"https://api.github.com/users/fiorix/gists{/gist_id}","starred_url":"https://api.github.com/users/fiorix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fiorix/subscriptions","organizations_url":"https://api.github.com/users/fiorix/orgs","repos_url":"https://api.github.com/users/fiorix/repos","events_url":"https://api.github.com/users/fiorix/events{/privacy}","received_events_url":"https://api.github.com/users/fiorix/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/fiorix/go-diameter","description":"Diameter stack and Base Protocol for the Go programming language","fork":false,"url":"https://api.github.com/repos/fiorix/go-diameter","forks_url":"https://api.github.com/repos/fiorix/go-diameter/forks","keys_url":"https://api.github.com/repos/fiorix/go-diameter/keys{/key_id}","collaborators_url":"https://api.github.com/repos/fiorix/go-diameter/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/fiorix/go-diameter/teams","hooks_url":"https://api.github.com/repos/fiorix/go-diameter/hooks","issue_events_url":"https://api.github.com/repos/fiorix/go-diameter/issues/events{/number}","events_url":"https://api.github.com/repos/fiorix/go-diameter/events","assignees_url":"https://api.github.com/repos/fiorix/go-diameter/assignees{/user}","branches_url":"https://api.github.com/repos/fiorix/go-diameter/branches{/branch}","tags_url":"https://api.github.com/repos/fiorix/go-diameter/tags","blobs_url":"https://api.github.com/repos/fiorix/go-diameter/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/fiorix/go-diameter/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/fiorix/go-diameter/git/refs{/sha}","trees_url":"https://api.github.com/repos/fiorix/go-diameter/git/trees{/sha}","statuses_url":"https://api.github.com/repos/fiorix/go-diameter/statuses/{sha}","languages_url":"https://api.github.com/repos/fiorix/go-diameter/languages","stargazers_url":"https://api.github.com/repos/fiorix/go-diameter/stargazers","contributors_url":"https://api.github.com/repos/fiorix/go-diameter/contributors","subscribers_url":"https://api.github.com/repos/fiorix/go-diameter/subscribers","subscription_url":"https://api.github.com/repos/fiorix/go-diameter/subscription","commits_url":"https://api.github.com/repos/fiorix/go-diameter/commits{/sha}","git_commits_url":"https://api.github.com/repos/fiorix/go-diameter/git/commits{/sha}","comments_url":"https://api.github.com/repos/fiorix/go-diameter/comments{/number}","issue_comment_url":"https://api.github.com/repos/fiorix/go-diameter/issues/comments/{number}","contents_url":"https://api.github.com/repos/fiorix/go-diameter/contents/{+path}","compare_url":"https://api.github.com/repos/fiorix/go-diameter/compare/{base}...{head}","merges_url":"https://api.github.com/repos/fiorix/go-diameter/merges","archive_url":"https://api.github.com/repos/fiorix/go-diameter/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/fiorix/go-diameter/downloads","issues_url":"https://api.github.com/repos/fiorix/go-diameter/issues{/number}","pulls_url":"https://api.github.com/repos/fiorix/go-diameter/pulls{/number}","milestones_url":"https://api.github.com/repos/fiorix/go-diameter/milestones{/number}","notifications_url":"https://api.github.com/repos/fiorix/go-diameter/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/fiorix/go-diameter/labels{/name}","releases_url":"https://api.github.com/repos/fiorix/go-diameter/releases{/id}","created_at":"2013-08-18T07:08:41Z","updated_at":"2015-02-12T21:42:01Z","pushed_at":"2015-02-12T22:22:21Z","git_url":"git://github.com/fiorix/go-diameter.git","ssh_url":"git@github.com:fiorix/go-diameter.git","clone_url":"https://github.com/fiorix/go-diameter.git","svn_url":"https://github.com/fiorix/go-diameter","homepage":"","size":2697,"stargazers_count":22,"watchers_count":22,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":5,"mirror_url":null,"open_issues_count":0,"forks":5,"open_issues":0,"watchers":22,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/fiorix/go-diameter/pulls/10"},"html":{"href":"https://github.com/fiorix/go-diameter/pull/10"},"issue":{"href":"https://api.github.com/repos/fiorix/go-diameter/issues/10"},"comments":{"href":"https://api.github.com/repos/fiorix/go-diameter/issues/10/comments"},"review_comments":{"href":"https://api.github.com/repos/fiorix/go-diameter/pulls/10/comments"},"review_comment":{"href":"https://api.github.com/repos/fiorix/go-diameter/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/fiorix/go-diameter/pulls/10/commits"},"statuses":{"href":"https://api.github.com/repos/fiorix/go-diameter/statuses/c0cfaaac37af04616666a4b31014d9a4a8b04479"}},"merged":true,"mergeable":null,"mergeable_state":"unknown","merged_by":{"login":"fiorix","id":129742,"avatar_url":"https://avatars.githubusercontent.com/u/129742?v=3","gravatar_id":"","url":"https://api.github.com/users/fiorix","html_url":"https://github.com/fiorix","followers_url":"https://api.github.com/users/fiorix/followers","following_url":"https://api.github.com/users/fiorix/following{/other_user}","gists_url":"https://api.github.com/users/fiorix/gists{/gist_id}","starred_url":"https://api.github.com/users/fiorix/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fiorix/subscriptions","organizations_url":"https://api.github.com/users/fiorix/orgs","repos_url":"https://api.github.com/users/fiorix/repos","events_url":"https://api.github.com/users/fiorix/events{/privacy}","received_events_url":"https://api.github.com/users/fiorix/received_events","type":"User","site_admin":false},"comments":5,"review_comments":0,"commits":2,"additions":29,"deletions":19,"changed_files":1}}