{"action":"created","comment":{"url":"https://api.github.com/repos/yegor256/takes/pulls/comments/43572107","id":43572107,"diff_hunk":"@@ -0,0 +1,144 @@\n+/**\n+ * The MIT License (MIT)\n+ *\n+ * Copyright (c) 2015 Yegor Bugayenko\n+ *\n+ * Permission is hereby granted, free of charge, to any person obtaining a copy\n+ * of this software and associated documentation files (the \"Software\"), to deal\n+ * in the Software without restriction, including without limitation the rights\n+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell\n+ * copies of the Software, and to permit persons to whom the Software is\n+ * furnished to do so, subject to the following conditions:\n+ *\n+ * The above copyright notice and this permission notice shall be included\n+ * in all copies or substantial portions of the Software.\n+ *\n+ * THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR\n+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,\n+ * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE\n+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER\n+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,\n+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE\n+ * SOFTWARE.\n+ */\n+package org.takes.tk;\n+\n+import java.io.IOException;\n+import lombok.EqualsAndHashCode;\n+import lombok.ToString;\n+import org.takes.Request;\n+import org.takes.Response;\n+import org.takes.Take;\n+\n+/**\n+ * Proxy take.\n+ *\n+ * <p>This take may transform the request before passing it\n+ * to the original take and/or transform the response received\n+ * from the original take.\n+ *\n+ * <p>If the request transformer is not provided, the original\n+ * request is passed to the original take.\n+ *\n+ * <p>If the response transformer is not provided, the response\n+ * received from the original take is returned.\n+ *\n+ * <p>The class is immutable and thread-safe.\n+ *\n+ * @author Dragan Bozanovic (bozanovicdr@gmail.com)\n+ * @version $Id$\n+ * @since 0.25\n+ */\n+@ToString\n+@EqualsAndHashCode\n+public final class TkProxy implements Take {\n+\n+    /**\n+     * Original take.\n+     */\n+    private final transient Take origin;\n+\n+    /**\n+     * Request transformer.\n+     */\n+    private final transient RqTransformer rqtransformer;\n+\n+    /**\n+     * Response transformer.\n+     */\n+    private final transient RsTransformer rstransformer;\n+\n+    /**\n+     * Ctor.\n+     * @param take Original take\n+     * @param rqtransformr Request transformer\n+     * @param rstransformr Response transformer\n+     */\n+    public TkProxy(final Take take, final RqTransformer rqtransformr,\n+            final RsTransformer rstransformr) {\n+        this.origin = take;\n+        this.rqtransformer = rqtransformr;\n+        this.rstransformer = rstransformr;\n+    }\n+\n+    /**\n+     * Ctor.\n+     * @param take Original take\n+     * @param rqtransformr Request transformer\n+     */\n+    public TkProxy(final Take take, final RqTransformer rqtransformr) {\n+        this(take, rqtransformr, new RsTransformer() {\n+            @Override\n+            public Response transform(final Response response) {\n+                return response;\n+            }\n+        });\n+    }\n+\n+    /**\n+     * Ctor.\n+     * @param take Original take\n+     * @param rstransformr Response transformer\n+     */\n+    public TkProxy(final Take take, final RsTransformer rstransformr) {\n+        this(take, new RqTransformer() {\n+            @Override\n+            public Request transform(final Request request) {\n+                return request;\n+            }\n+        }, rstransformr);\n+    }\n+\n+    @Override\n+    public Response act(final Request req) throws IOException {\n+        final Request transformed = this.rqtransformer.transform(req);\n+        final Response response = this.origin.act(transformed);","path":"src/main/java/org/takes/tk/TkProxy.java","position":115,"original_position":115,"commit_id":"1faf82728d13368dbaebf1f31d8c5f4e5f076ce7","original_commit_id":"1faf82728d13368dbaebf1f31d8c5f4e5f076ce7","user":{"login":"dmzaytsev","id":9972909,"avatar_url":"https://avatars.githubusercontent.com/u/9972909?v=3","gravatar_id":"","url":"https://api.github.com/users/dmzaytsev","html_url":"https://github.com/dmzaytsev","followers_url":"https://api.github.com/users/dmzaytsev/followers","following_url":"https://api.github.com/users/dmzaytsev/following{/other_user}","gists_url":"https://api.github.com/users/dmzaytsev/gists{/gist_id}","starred_url":"https://api.github.com/users/dmzaytsev/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dmzaytsev/subscriptions","organizations_url":"https://api.github.com/users/dmzaytsev/orgs","repos_url":"https://api.github.com/users/dmzaytsev/repos","events_url":"https://api.github.com/users/dmzaytsev/events{/privacy}","received_events_url":"https://api.github.com/users/dmzaytsev/received_events","type":"User","site_admin":false},"body":"@bdragan `transformed` variable is redundant, it can be inline ","created_at":"2015-10-31T14:12:45Z","updated_at":"2015-10-31T14:12:45Z","html_url":"https://github.com/yegor256/takes/pull/421#discussion_r43572107","pull_request_url":"https://api.github.com/repos/yegor256/takes/pulls/421","_links":{"self":{"href":"https://api.github.com/repos/yegor256/takes/pulls/comments/43572107"},"html":{"href":"https://github.com/yegor256/takes/pull/421#discussion_r43572107"},"pull_request":{"href":"https://api.github.com/repos/yegor256/takes/pulls/421"}}},"pull_request":{"url":"https://api.github.com/repos/yegor256/takes/pulls/421","id":49322574,"html_url":"https://github.com/yegor256/takes/pull/421","diff_url":"https://github.com/yegor256/takes/pull/421.diff","patch_url":"https://github.com/yegor256/takes/pull/421.patch","issue_url":"https://api.github.com/repos/yegor256/takes/issues/421","number":421,"state":"open","locked":false,"title":"#377: Added TkProxy class","user":{"login":"bdragan","id":8607452,"avatar_url":"https://avatars.githubusercontent.com/u/8607452?v=3","gravatar_id":"","url":"https://api.github.com/users/bdragan","html_url":"https://github.com/bdragan","followers_url":"https://api.github.com/users/bdragan/followers","following_url":"https://api.github.com/users/bdragan/following{/other_user}","gists_url":"https://api.github.com/users/bdragan/gists{/gist_id}","starred_url":"https://api.github.com/users/bdragan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdragan/subscriptions","organizations_url":"https://api.github.com/users/bdragan/orgs","repos_url":"https://api.github.com/users/bdragan/repos","events_url":"https://api.github.com/users/bdragan/events{/privacy}","received_events_url":"https://api.github.com/users/bdragan/received_events","type":"User","site_admin":false},"body":"#377: Added TkProxy class.","created_at":"2015-10-30T21:07:16Z","updated_at":"2015-10-31T14:12:45Z","closed_at":null,"merged_at":null,"merge_commit_sha":"75667eb2a0a545cf8547cfebc765c23b513cdda4","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/yegor256/takes/pulls/421/commits","review_comments_url":"https://api.github.com/repos/yegor256/takes/pulls/421/comments","review_comment_url":"https://api.github.com/repos/yegor256/takes/pulls/comments{/number}","comments_url":"https://api.github.com/repos/yegor256/takes/issues/421/comments","statuses_url":"https://api.github.com/repos/yegor256/takes/statuses/1faf82728d13368dbaebf1f31d8c5f4e5f076ce7","head":{"label":"bdragan:377","ref":"377","sha":"1faf82728d13368dbaebf1f31d8c5f4e5f076ce7","user":{"login":"bdragan","id":8607452,"avatar_url":"https://avatars.githubusercontent.com/u/8607452?v=3","gravatar_id":"","url":"https://api.github.com/users/bdragan","html_url":"https://github.com/bdragan","followers_url":"https://api.github.com/users/bdragan/followers","following_url":"https://api.github.com/users/bdragan/following{/other_user}","gists_url":"https://api.github.com/users/bdragan/gists{/gist_id}","starred_url":"https://api.github.com/users/bdragan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdragan/subscriptions","organizations_url":"https://api.github.com/users/bdragan/orgs","repos_url":"https://api.github.com/users/bdragan/repos","events_url":"https://api.github.com/users/bdragan/events{/privacy}","received_events_url":"https://api.github.com/users/bdragan/received_events","type":"User","site_admin":false},"repo":{"id":43305752,"name":"takes","full_name":"bdragan/takes","owner":{"login":"bdragan","id":8607452,"avatar_url":"https://avatars.githubusercontent.com/u/8607452?v=3","gravatar_id":"","url":"https://api.github.com/users/bdragan","html_url":"https://github.com/bdragan","followers_url":"https://api.github.com/users/bdragan/followers","following_url":"https://api.github.com/users/bdragan/following{/other_user}","gists_url":"https://api.github.com/users/bdragan/gists{/gist_id}","starred_url":"https://api.github.com/users/bdragan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bdragan/subscriptions","organizations_url":"https://api.github.com/users/bdragan/orgs","repos_url":"https://api.github.com/users/bdragan/repos","events_url":"https://api.github.com/users/bdragan/events{/privacy}","received_events_url":"https://api.github.com/users/bdragan/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/bdragan/takes","description":"True Object-Oriented and Immutable Java Web Framework","fork":true,"url":"https://api.github.com/repos/bdragan/takes","forks_url":"https://api.github.com/repos/bdragan/takes/forks","keys_url":"https://api.github.com/repos/bdragan/takes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/bdragan/takes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/bdragan/takes/teams","hooks_url":"https://api.github.com/repos/bdragan/takes/hooks","issue_events_url":"https://api.github.com/repos/bdragan/takes/issues/events{/number}","events_url":"https://api.github.com/repos/bdragan/takes/events","assignees_url":"https://api.github.com/repos/bdragan/takes/assignees{/user}","branches_url":"https://api.github.com/repos/bdragan/takes/branches{/branch}","tags_url":"https://api.github.com/repos/bdragan/takes/tags","blobs_url":"https://api.github.com/repos/bdragan/takes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/bdragan/takes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/bdragan/takes/git/refs{/sha}","trees_url":"https://api.github.com/repos/bdragan/takes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/bdragan/takes/statuses/{sha}","languages_url":"https://api.github.com/repos/bdragan/takes/languages","stargazers_url":"https://api.github.com/repos/bdragan/takes/stargazers","contributors_url":"https://api.github.com/repos/bdragan/takes/contributors","subscribers_url":"https://api.github.com/repos/bdragan/takes/subscribers","subscription_url":"https://api.github.com/repos/bdragan/takes/subscription","commits_url":"https://api.github.com/repos/bdragan/takes/commits{/sha}","git_commits_url":"https://api.github.com/repos/bdragan/takes/git/commits{/sha}","comments_url":"https://api.github.com/repos/bdragan/takes/comments{/number}","issue_comment_url":"https://api.github.com/repos/bdragan/takes/issues/comments{/number}","contents_url":"https://api.github.com/repos/bdragan/takes/contents/{+path}","compare_url":"https://api.github.com/repos/bdragan/takes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/bdragan/takes/merges","archive_url":"https://api.github.com/repos/bdragan/takes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/bdragan/takes/downloads","issues_url":"https://api.github.com/repos/bdragan/takes/issues{/number}","pulls_url":"https://api.github.com/repos/bdragan/takes/pulls{/number}","milestones_url":"https://api.github.com/repos/bdragan/takes/milestones{/number}","notifications_url":"https://api.github.com/repos/bdragan/takes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/bdragan/takes/labels{/name}","releases_url":"https://api.github.com/repos/bdragan/takes/releases{/id}","created_at":"2015-09-28T14:26:04Z","updated_at":"2015-09-28T14:26:10Z","pushed_at":"2015-10-30T21:06:15Z","git_url":"git://github.com/bdragan/takes.git","ssh_url":"git@github.com:bdragan/takes.git","clone_url":"https://github.com/bdragan/takes.git","svn_url":"https://github.com/bdragan/takes","homepage":"http://www.takes.org","size":27845,"stargazers_count":0,"watchers_count":0,"language":"Java","has_issues":false,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"yegor256:master","ref":"master","sha":"50efd095b5c85764c4aaeb8e4b9b2baa8d9d3e3a","user":{"login":"yegor256","id":526301,"avatar_url":"https://avatars.githubusercontent.com/u/526301?v=3","gravatar_id":"","url":"https://api.github.com/users/yegor256","html_url":"https://github.com/yegor256","followers_url":"https://api.github.com/users/yegor256/followers","following_url":"https://api.github.com/users/yegor256/following{/other_user}","gists_url":"https://api.github.com/users/yegor256/gists{/gist_id}","starred_url":"https://api.github.com/users/yegor256/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yegor256/subscriptions","organizations_url":"https://api.github.com/users/yegor256/orgs","repos_url":"https://api.github.com/users/yegor256/repos","events_url":"https://api.github.com/users/yegor256/events{/privacy}","received_events_url":"https://api.github.com/users/yegor256/received_events","type":"User","site_admin":false},"repo":{"id":28924109,"name":"takes","full_name":"yegor256/takes","owner":{"login":"yegor256","id":526301,"avatar_url":"https://avatars.githubusercontent.com/u/526301?v=3","gravatar_id":"","url":"https://api.github.com/users/yegor256","html_url":"https://github.com/yegor256","followers_url":"https://api.github.com/users/yegor256/followers","following_url":"https://api.github.com/users/yegor256/following{/other_user}","gists_url":"https://api.github.com/users/yegor256/gists{/gist_id}","starred_url":"https://api.github.com/users/yegor256/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/yegor256/subscriptions","organizations_url":"https://api.github.com/users/yegor256/orgs","repos_url":"https://api.github.com/users/yegor256/repos","events_url":"https://api.github.com/users/yegor256/events{/privacy}","received_events_url":"https://api.github.com/users/yegor256/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/yegor256/takes","description":"True Object-Oriented and Immutable Java Web Framework","fork":false,"url":"https://api.github.com/repos/yegor256/takes","forks_url":"https://api.github.com/repos/yegor256/takes/forks","keys_url":"https://api.github.com/repos/yegor256/takes/keys{/key_id}","collaborators_url":"https://api.github.com/repos/yegor256/takes/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/yegor256/takes/teams","hooks_url":"https://api.github.com/repos/yegor256/takes/hooks","issue_events_url":"https://api.github.com/repos/yegor256/takes/issues/events{/number}","events_url":"https://api.github.com/repos/yegor256/takes/events","assignees_url":"https://api.github.com/repos/yegor256/takes/assignees{/user}","branches_url":"https://api.github.com/repos/yegor256/takes/branches{/branch}","tags_url":"https://api.github.com/repos/yegor256/takes/tags","blobs_url":"https://api.github.com/repos/yegor256/takes/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/yegor256/takes/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/yegor256/takes/git/refs{/sha}","trees_url":"https://api.github.com/repos/yegor256/takes/git/trees{/sha}","statuses_url":"https://api.github.com/repos/yegor256/takes/statuses/{sha}","languages_url":"https://api.github.com/repos/yegor256/takes/languages","stargazers_url":"https://api.github.com/repos/yegor256/takes/stargazers","contributors_url":"https://api.github.com/repos/yegor256/takes/contributors","subscribers_url":"https://api.github.com/repos/yegor256/takes/subscribers","subscription_url":"https://api.github.com/repos/yegor256/takes/subscription","commits_url":"https://api.github.com/repos/yegor256/takes/commits{/sha}","git_commits_url":"https://api.github.com/repos/yegor256/takes/git/commits{/sha}","comments_url":"https://api.github.com/repos/yegor256/takes/comments{/number}","issue_comment_url":"https://api.github.com/repos/yegor256/takes/issues/comments{/number}","contents_url":"https://api.github.com/repos/yegor256/takes/contents/{+path}","compare_url":"https://api.github.com/repos/yegor256/takes/compare/{base}...{head}","merges_url":"https://api.github.com/repos/yegor256/takes/merges","archive_url":"https://api.github.com/repos/yegor256/takes/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/yegor256/takes/downloads","issues_url":"https://api.github.com/repos/yegor256/takes/issues{/number}","pulls_url":"https://api.github.com/repos/yegor256/takes/pulls{/number}","milestones_url":"https://api.github.com/repos/yegor256/takes/milestones{/number}","notifications_url":"https://api.github.com/repos/yegor256/takes/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/yegor256/takes/labels{/name}","releases_url":"https://api.github.com/repos/yegor256/takes/releases{/id}","created_at":"2015-01-07T16:57:47Z","updated_at":"2015-10-28T13:43:44Z","pushed_at":"2015-10-31T06:49:17Z","git_url":"git://github.com/yegor256/takes.git","ssh_url":"git@github.com:yegor256/takes.git","clone_url":"https://github.com/yegor256/takes.git","svn_url":"https://github.com/yegor256/takes","homepage":"http://www.takes.org","size":38210,"stargazers_count":110,"watchers_count":110,"language":"Java","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":true,"forks_count":53,"mirror_url":null,"open_issues_count":34,"forks":53,"open_issues":34,"watchers":110,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/yegor256/takes/pulls/421"},"html":{"href":"https://github.com/yegor256/takes/pull/421"},"issue":{"href":"https://api.github.com/repos/yegor256/takes/issues/421"},"comments":{"href":"https://api.github.com/repos/yegor256/takes/issues/421/comments"},"review_comments":{"href":"https://api.github.com/repos/yegor256/takes/pulls/421/comments"},"review_comment":{"href":"https://api.github.com/repos/yegor256/takes/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/yegor256/takes/pulls/421/commits"},"statuses":{"href":"https://api.github.com/repos/yegor256/takes/statuses/1faf82728d13368dbaebf1f31d8c5f4e5f076ce7"}}}}