{"action":"created","comment":{"url":"https://api.github.com/repos/univedo/api2go/pulls/comments/26025707","id":26025707,"diff_hunk":"@@ -213,11 +238,18 @@ func (ctx *marshalingContext) marshalStruct(val *reflect.Value, isLinked bool) e\n \t\t\t\t}\n \t\t\t\tif id != \"\" {\n \t\t\t\t\tlinksMap[keyNameWithoutID] = map[string]interface{}{\n-\t\t\t\t\t\t\"id\":   id,\n-\t\t\t\t\t\t\"type\": pluralize(jsonify(structFieldValue.Type().Elem().Name())),\n+\t\t\t\t\t\t\"id\":       id,\n+\t\t\t\t\t\t\"type\":     pluralize(jsonify(structFieldValue.Type().Elem().Name())),\n+\t\t\t\t\t\t\"resource\": fmt.Sprintf(\"/%s/%s/%s\", name, result[\"id\"], keyNameWithoutID),\n \t\t\t\t\t}\n \t\t\t\t} else {\n-\t\t\t\t\tlinksMap[keyNameWithoutID] = nil\n+\t\t\t\t\tlinksMap[keyNameWithoutID] = map[string]interface{}{\n+\t\t\t\t\t\t\"type\":     pluralize(jsonify(structFieldValue.Type().Elem().Name())),\n+\t\t\t\t\t\t\"resource\": fmt.Sprintf(\"/%s/%s/%s\", name, result[\"id\"], keyNameWithoutID),\n+\t\t\t\t\t}\n+\t\t\t\t}\n+\t\t\t\tif ctx.prefix != \"/\" {\n+\t\t\t\t\tlinksMap[keyNameWithoutID].(map[string]interface{})[\"resource\"] = fmt.Sprintf(\"%s%s\", ctx.prefix, linksMap[keyNameWithoutID].(map[string]interface{})[\"resource\"])","path":"marshal.go","position":124,"original_position":124,"commit_id":"dce2c43d9354cc3f8752c0b194cc6fb606289899","original_commit_id":"dce2c43d9354cc3f8752c0b194cc6fb606289899","user":{"login":"wwwdata","id":818880,"avatar_url":"https://avatars.githubusercontent.com/u/818880?v=3","gravatar_id":"","url":"https://api.github.com/users/wwwdata","html_url":"https://github.com/wwwdata","followers_url":"https://api.github.com/users/wwwdata/followers","following_url":"https://api.github.com/users/wwwdata/following{/other_user}","gists_url":"https://api.github.com/users/wwwdata/gists{/gist_id}","starred_url":"https://api.github.com/users/wwwdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wwwdata/subscriptions","organizations_url":"https://api.github.com/users/wwwdata/orgs","repos_url":"https://api.github.com/users/wwwdata/repos","events_url":"https://api.github.com/users/wwwdata/events{/privacy}","received_events_url":"https://api.github.com/users/wwwdata/received_events","type":"User","site_admin":false},"body":"I will change that so that casting is not needed anymore","created_at":"2015-03-09T10:35:15Z","updated_at":"2015-03-09T10:35:15Z","html_url":"https://github.com/univedo/api2go/pull/68#discussion_r26025707","pull_request_url":"https://api.github.com/repos/univedo/api2go/pulls/68","_links":{"self":{"href":"https://api.github.com/repos/univedo/api2go/pulls/comments/26025707"},"html":{"href":"https://github.com/univedo/api2go/pull/68#discussion_r26025707"},"pull_request":{"href":"https://api.github.com/repos/univedo/api2go/pulls/68"}}},"pull_request":{"url":"https://api.github.com/repos/univedo/api2go/pulls/68","id":30701715,"html_url":"https://github.com/univedo/api2go/pull/68","diff_url":"https://github.com/univedo/api2go/pull/68.diff","patch_url":"https://github.com/univedo/api2go/pull/68.patch","issue_url":"https://api.github.com/repos/univedo/api2go/issues/68","number":68,"state":"open","locked":false,"title":"Resource links","user":{"login":"wwwdata","id":818880,"avatar_url":"https://avatars.githubusercontent.com/u/818880?v=3","gravatar_id":"","url":"https://api.github.com/users/wwwdata","html_url":"https://github.com/wwwdata","followers_url":"https://api.github.com/users/wwwdata/followers","following_url":"https://api.github.com/users/wwwdata/following{/other_user}","gists_url":"https://api.github.com/users/wwwdata/gists{/gist_id}","starred_url":"https://api.github.com/users/wwwdata/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/wwwdata/subscriptions","organizations_url":"https://api.github.com/users/wwwdata/orgs","repos_url":"https://api.github.com/users/wwwdata/repos","events_url":"https://api.github.com/users/wwwdata/events{/privacy}","received_events_url":"https://api.github.com/users/wwwdata/received_events","type":"User","site_admin":false},"body":"This PR introduces the possibility to not specify any related IDs at all and just let a link be auto generated for the client to load related data. See http://jsonapi.org/format/#document-structure-resource-relationships\r\n\r\nThis introduces the `resource` member in the links object. The resource URL get's automatically generated by Marshalling a struct manually and via the API. For manually marshalling, I introduced 2 more methods to specify a API Prefix. This is now needed because before this feature, the serialisation had nothing to do with URLs. \r\n\r\nSo, a new GET Route get's created for referenced structs now like `/v1/posts/1/comments`. If a client requests this URL, the request get's routed to the `FindAll` method of the Resource for `comments` with a Query parameter `PostsID` which in this example has the value 1.\r\n\r\nPlease let me know what you think about that. \r\n\r\nWhat I am wondering is whether it is to required to also include the hostname in the `resource` field for the URL. What we now also could easily implement is the `self` field. But I left that out for now, because we do not generate routes for relationships at the moment.","created_at":"2015-03-07T11:49:40Z","updated_at":"2015-03-09T10:35:16Z","closed_at":null,"merged_at":null,"merge_commit_sha":"4d4ca2a35f49260b2542d8f644f269afaead8a0f","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/univedo/api2go/pulls/68/commits","review_comments_url":"https://api.github.com/repos/univedo/api2go/pulls/68/comments","review_comment_url":"https://api.github.com/repos/univedo/api2go/pulls/comments{/number}","comments_url":"https://api.github.com/repos/univedo/api2go/issues/68/comments","statuses_url":"https://api.github.com/repos/univedo/api2go/statuses/dce2c43d9354cc3f8752c0b194cc6fb606289899","head":{"label":"univedo:resourceLinks","ref":"resourceLinks","sha":"dce2c43d9354cc3f8752c0b194cc6fb606289899","user":{"login":"univedo","id":6825049,"avatar_url":"https://avatars.githubusercontent.com/u/6825049?v=3","gravatar_id":"","url":"https://api.github.com/users/univedo","html_url":"https://github.com/univedo","followers_url":"https://api.github.com/users/univedo/followers","following_url":"https://api.github.com/users/univedo/following{/other_user}","gists_url":"https://api.github.com/users/univedo/gists{/gist_id}","starred_url":"https://api.github.com/users/univedo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/univedo/subscriptions","organizations_url":"https://api.github.com/users/univedo/orgs","repos_url":"https://api.github.com/users/univedo/repos","events_url":"https://api.github.com/users/univedo/events{/privacy}","received_events_url":"https://api.github.com/users/univedo/received_events","type":"Organization","site_admin":false},"repo":{"id":23196256,"name":"api2go","full_name":"univedo/api2go","owner":{"login":"univedo","id":6825049,"avatar_url":"https://avatars.githubusercontent.com/u/6825049?v=3","gravatar_id":"","url":"https://api.github.com/users/univedo","html_url":"https://github.com/univedo","followers_url":"https://api.github.com/users/univedo/followers","following_url":"https://api.github.com/users/univedo/following{/other_user}","gists_url":"https://api.github.com/users/univedo/gists{/gist_id}","starred_url":"https://api.github.com/users/univedo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/univedo/subscriptions","organizations_url":"https://api.github.com/users/univedo/orgs","repos_url":"https://api.github.com/users/univedo/repos","events_url":"https://api.github.com/users/univedo/events{/privacy}","received_events_url":"https://api.github.com/users/univedo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/univedo/api2go","description":"JSONAPI.org Implementation for Go","fork":false,"url":"https://api.github.com/repos/univedo/api2go","forks_url":"https://api.github.com/repos/univedo/api2go/forks","keys_url":"https://api.github.com/repos/univedo/api2go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/univedo/api2go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/univedo/api2go/teams","hooks_url":"https://api.github.com/repos/univedo/api2go/hooks","issue_events_url":"https://api.github.com/repos/univedo/api2go/issues/events{/number}","events_url":"https://api.github.com/repos/univedo/api2go/events","assignees_url":"https://api.github.com/repos/univedo/api2go/assignees{/user}","branches_url":"https://api.github.com/repos/univedo/api2go/branches{/branch}","tags_url":"https://api.github.com/repos/univedo/api2go/tags","blobs_url":"https://api.github.com/repos/univedo/api2go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/univedo/api2go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/univedo/api2go/git/refs{/sha}","trees_url":"https://api.github.com/repos/univedo/api2go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/univedo/api2go/statuses/{sha}","languages_url":"https://api.github.com/repos/univedo/api2go/languages","stargazers_url":"https://api.github.com/repos/univedo/api2go/stargazers","contributors_url":"https://api.github.com/repos/univedo/api2go/contributors","subscribers_url":"https://api.github.com/repos/univedo/api2go/subscribers","subscription_url":"https://api.github.com/repos/univedo/api2go/subscription","commits_url":"https://api.github.com/repos/univedo/api2go/commits{/sha}","git_commits_url":"https://api.github.com/repos/univedo/api2go/git/commits{/sha}","comments_url":"https://api.github.com/repos/univedo/api2go/comments{/number}","issue_comment_url":"https://api.github.com/repos/univedo/api2go/issues/comments{/number}","contents_url":"https://api.github.com/repos/univedo/api2go/contents/{+path}","compare_url":"https://api.github.com/repos/univedo/api2go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/univedo/api2go/merges","archive_url":"https://api.github.com/repos/univedo/api2go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/univedo/api2go/downloads","issues_url":"https://api.github.com/repos/univedo/api2go/issues{/number}","pulls_url":"https://api.github.com/repos/univedo/api2go/pulls{/number}","milestones_url":"https://api.github.com/repos/univedo/api2go/milestones{/number}","notifications_url":"https://api.github.com/repos/univedo/api2go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/univedo/api2go/labels{/name}","releases_url":"https://api.github.com/repos/univedo/api2go/releases{/id}","created_at":"2014-08-21T17:23:27Z","updated_at":"2015-03-08T13:59:05Z","pushed_at":"2015-03-07T11:59:44Z","git_url":"git://github.com/univedo/api2go.git","ssh_url":"git@github.com:univedo/api2go.git","clone_url":"https://github.com/univedo/api2go.git","svn_url":"https://github.com/univedo/api2go","homepage":"","size":777,"stargazers_count":60,"watchers_count":60,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":9,"forks":3,"open_issues":9,"watchers":60,"default_branch":"master"}},"base":{"label":"univedo:master","ref":"master","sha":"0fbfb39e0cf75e82e71709dd61f9988818437e2e","user":{"login":"univedo","id":6825049,"avatar_url":"https://avatars.githubusercontent.com/u/6825049?v=3","gravatar_id":"","url":"https://api.github.com/users/univedo","html_url":"https://github.com/univedo","followers_url":"https://api.github.com/users/univedo/followers","following_url":"https://api.github.com/users/univedo/following{/other_user}","gists_url":"https://api.github.com/users/univedo/gists{/gist_id}","starred_url":"https://api.github.com/users/univedo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/univedo/subscriptions","organizations_url":"https://api.github.com/users/univedo/orgs","repos_url":"https://api.github.com/users/univedo/repos","events_url":"https://api.github.com/users/univedo/events{/privacy}","received_events_url":"https://api.github.com/users/univedo/received_events","type":"Organization","site_admin":false},"repo":{"id":23196256,"name":"api2go","full_name":"univedo/api2go","owner":{"login":"univedo","id":6825049,"avatar_url":"https://avatars.githubusercontent.com/u/6825049?v=3","gravatar_id":"","url":"https://api.github.com/users/univedo","html_url":"https://github.com/univedo","followers_url":"https://api.github.com/users/univedo/followers","following_url":"https://api.github.com/users/univedo/following{/other_user}","gists_url":"https://api.github.com/users/univedo/gists{/gist_id}","starred_url":"https://api.github.com/users/univedo/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/univedo/subscriptions","organizations_url":"https://api.github.com/users/univedo/orgs","repos_url":"https://api.github.com/users/univedo/repos","events_url":"https://api.github.com/users/univedo/events{/privacy}","received_events_url":"https://api.github.com/users/univedo/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/univedo/api2go","description":"JSONAPI.org Implementation for Go","fork":false,"url":"https://api.github.com/repos/univedo/api2go","forks_url":"https://api.github.com/repos/univedo/api2go/forks","keys_url":"https://api.github.com/repos/univedo/api2go/keys{/key_id}","collaborators_url":"https://api.github.com/repos/univedo/api2go/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/univedo/api2go/teams","hooks_url":"https://api.github.com/repos/univedo/api2go/hooks","issue_events_url":"https://api.github.com/repos/univedo/api2go/issues/events{/number}","events_url":"https://api.github.com/repos/univedo/api2go/events","assignees_url":"https://api.github.com/repos/univedo/api2go/assignees{/user}","branches_url":"https://api.github.com/repos/univedo/api2go/branches{/branch}","tags_url":"https://api.github.com/repos/univedo/api2go/tags","blobs_url":"https://api.github.com/repos/univedo/api2go/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/univedo/api2go/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/univedo/api2go/git/refs{/sha}","trees_url":"https://api.github.com/repos/univedo/api2go/git/trees{/sha}","statuses_url":"https://api.github.com/repos/univedo/api2go/statuses/{sha}","languages_url":"https://api.github.com/repos/univedo/api2go/languages","stargazers_url":"https://api.github.com/repos/univedo/api2go/stargazers","contributors_url":"https://api.github.com/repos/univedo/api2go/contributors","subscribers_url":"https://api.github.com/repos/univedo/api2go/subscribers","subscription_url":"https://api.github.com/repos/univedo/api2go/subscription","commits_url":"https://api.github.com/repos/univedo/api2go/commits{/sha}","git_commits_url":"https://api.github.com/repos/univedo/api2go/git/commits{/sha}","comments_url":"https://api.github.com/repos/univedo/api2go/comments{/number}","issue_comment_url":"https://api.github.com/repos/univedo/api2go/issues/comments{/number}","contents_url":"https://api.github.com/repos/univedo/api2go/contents/{+path}","compare_url":"https://api.github.com/repos/univedo/api2go/compare/{base}...{head}","merges_url":"https://api.github.com/repos/univedo/api2go/merges","archive_url":"https://api.github.com/repos/univedo/api2go/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/univedo/api2go/downloads","issues_url":"https://api.github.com/repos/univedo/api2go/issues{/number}","pulls_url":"https://api.github.com/repos/univedo/api2go/pulls{/number}","milestones_url":"https://api.github.com/repos/univedo/api2go/milestones{/number}","notifications_url":"https://api.github.com/repos/univedo/api2go/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/univedo/api2go/labels{/name}","releases_url":"https://api.github.com/repos/univedo/api2go/releases{/id}","created_at":"2014-08-21T17:23:27Z","updated_at":"2015-03-08T13:59:05Z","pushed_at":"2015-03-07T11:59:44Z","git_url":"git://github.com/univedo/api2go.git","ssh_url":"git@github.com:univedo/api2go.git","clone_url":"https://github.com/univedo/api2go.git","svn_url":"https://github.com/univedo/api2go","homepage":"","size":777,"stargazers_count":60,"watchers_count":60,"language":"Go","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"open_issues_count":9,"forks":3,"open_issues":9,"watchers":60,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/univedo/api2go/pulls/68"},"html":{"href":"https://github.com/univedo/api2go/pull/68"},"issue":{"href":"https://api.github.com/repos/univedo/api2go/issues/68"},"comments":{"href":"https://api.github.com/repos/univedo/api2go/issues/68/comments"},"review_comments":{"href":"https://api.github.com/repos/univedo/api2go/pulls/68/comments"},"review_comment":{"href":"https://api.github.com/repos/univedo/api2go/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/univedo/api2go/pulls/68/commits"},"statuses":{"href":"https://api.github.com/repos/univedo/api2go/statuses/dce2c43d9354cc3f8752c0b194cc6fb606289899"}}}}