{"action":"created","comment":{"url":"https://api.github.com/repos/aspnet/CORS/pulls/comments/25566412","id":25566412,"diff_hunk":"@@ -0,0 +1,193 @@\n+﻿// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved.\n+// Licensed under the Apache License, Version 2.0. See License.txt in the project root for license information.\n+\n+using System.Linq;\n+using Microsoft.AspNet.Cors.Core;\n+using Microsoft.Framework.Internal;\n+\n+namespace Microsoft.AspNet.Cors\n+{\n+    /// <summary>\n+    /// Exposes methods to build a policy.\n+    /// </summary>\n+    public class CorsPolicyBuilder\n+    {\n+        private readonly CorsPolicy _policy = new CorsPolicy();\n+\n+        /// <summary>\n+        /// Creates a new instance of the <see cref=\"CorsPolicyBuilder\"/>.\n+        /// </summary>\n+        /// <param name=\"origins\">list of origins which can be added.</param>\n+        public CorsPolicyBuilder(params string[] origins)\n+        {\n+            AddOrigins(origins);\n+        }\n+\n+        /// <summary>\n+        /// Creates a new instance of the <see cref=\"CorsPolicyBuilder\"/>.\n+        /// </summary>\n+        /// <param name=\"policy\">The policy which will be used to intialize the builder.</param>\n+        public CorsPolicyBuilder(CorsPolicy policy)\n+        {\n+            Combine(policy);\n+        }\n+\n+        /// <summary>\n+        /// Adds the specified <paramref name=\"origins\"/> to the policy.\n+        /// </summary>\n+        /// <param name=\"origins\">The origins that are allowed.</param>\n+        /// <returns>The current policy builder</returns>\n+        public CorsPolicyBuilder AddOrigins(params string[] origins)\n+        {\n+            foreach (var req in origins)\n+            {\n+                _policy.Origins.Add(req);\n+            }\n+\n+            return this;\n+        }\n+\n+        /// <summary>\n+        /// Adds the specified <paramref name=\"headers\"/> to the policy.\n+        /// </summary>\n+        /// <param name=\"headers\">The headers which need to be allowed in the request.</param>\n+        /// <returns>The current policy builder</returns>\n+        public CorsPolicyBuilder AddHeaders(params string[] headers)\n+        {\n+            foreach (var req in headers)\n+            {\n+                _policy.Headers.Add(req);\n+            }\n+            return this;\n+        }\n+\n+        /// <summary>\n+        /// Adds the specified <paramref name=\"exposedHeaders\"/> to the policy.\n+        /// </summary>\n+        /// <param name=\"exposedHeaders\">The headers which need to be exposed to the client.</param>\n+        /// <returns>The current policy builder</returns>\n+        public CorsPolicyBuilder AddExposedHeaders(params string[] exposedHeaders)\n+        {\n+            foreach (var req in exposedHeaders)\n+            {\n+                _policy.ExposedHeaders.Add(req);\n+            }\n+\n+            return this;\n+        }\n+\n+        /// <summary>\n+        /// Adds the specified <paramref name=\"methods\"/> to the policy.\n+        /// </summary>\n+        /// <param name=\"methods\">The methods which need to be added to the policy.</param>\n+        /// <returns>The current policy builder</returns>\n+        public CorsPolicyBuilder AddMethods(params string[] methods)\n+        {\n+            foreach (var req in methods)\n+            {\n+                _policy.Methods.Add(req);\n+            }\n+\n+            return this;\n+        }\n+\n+        /// <summary>\n+        /// Sets the policy to allow credentials.\n+        /// </summary>\n+        /// <returns>The current policy builder</returns>\n+        public CorsPolicyBuilder AllowCredentials()\n+        {\n+            _policy.SupportsCredentials = true;\n+            return this;\n+        }\n+\n+        /// <summary>\n+        /// Sets the policy to not allow credentials.\n+        /// </summary>\n+        /// <returns>The current policy builder</returns>\n+        public CorsPolicyBuilder DisallowCredentials()\n+        {\n+            _policy.SupportsCredentials = false;\n+            return this;\n+        }\n+\n+        /// <summary>\n+        /// Ensures that the policy allows any origin.\n+        /// </summary>\n+        /// <returns>The current policy builder</returns>\n+        public CorsPolicyBuilder AllowAnyOrigin()\n+        {\n+            _policy.Origins.Clear();\n+            _policy.Origins.Add(CorsConstants.AnyOrigin);\n+            return this;\n+        }\n+\n+        /// <summary>\n+        /// Ensures that the policy allows any method.\n+        /// </summary>\n+        /// <returns>The current policy builder</returns>\n+        public CorsPolicyBuilder AllowAnyMehtod()","path":"src/Microsoft.AspNet.Cors.Core/CorsPolicyBuilder.cs","position":129,"original_position":129,"commit_id":"e61a11e0128e93fbd717c02fde26a926a2b04841","original_commit_id":"e61a11e0128e93fbd717c02fde26a926a2b04841","user":{"login":"borgdylan","id":7761010,"avatar_url":"https://avatars.githubusercontent.com/u/7761010?v=3","gravatar_id":"","url":"https://api.github.com/users/borgdylan","html_url":"https://github.com/borgdylan","followers_url":"https://api.github.com/users/borgdylan/followers","following_url":"https://api.github.com/users/borgdylan/following{/other_user}","gists_url":"https://api.github.com/users/borgdylan/gists{/gist_id}","starred_url":"https://api.github.com/users/borgdylan/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/borgdylan/subscriptions","organizations_url":"https://api.github.com/users/borgdylan/orgs","repos_url":"https://api.github.com/users/borgdylan/repos","events_url":"https://api.github.com/users/borgdylan/events{/privacy}","received_events_url":"https://api.github.com/users/borgdylan/received_events","type":"User","site_admin":false},"body":"AllowAnyMethod?","created_at":"2015-03-01T11:27:25Z","updated_at":"2015-03-01T11:27:25Z","html_url":"https://github.com/aspnet/CORS/pull/3#discussion_r25566412","pull_request_url":"https://api.github.com/repos/aspnet/CORS/pulls/3","_links":{"self":{"href":"https://api.github.com/repos/aspnet/CORS/pulls/comments/25566412"},"html":{"href":"https://github.com/aspnet/CORS/pull/3#discussion_r25566412"},"pull_request":{"href":"https://api.github.com/repos/aspnet/CORS/pulls/3"}}},"pull_request":{"url":"https://api.github.com/repos/aspnet/CORS/pulls/3","id":30028761,"html_url":"https://github.com/aspnet/CORS/pull/3","diff_url":"https://github.com/aspnet/CORS/pull/3.diff","patch_url":"https://github.com/aspnet/CORS/pull/3.patch","issue_url":"https://api.github.com/repos/aspnet/CORS/issues/3","number":3,"state":"open","locked":false,"title":"Adding Base interfaces and implementation for Cors.Core","user":{"login":"harshgMSFT","id":6729943,"avatar_url":"https://avatars.githubusercontent.com/u/6729943?v=3","gravatar_id":"","url":"https://api.github.com/users/harshgMSFT","html_url":"https://github.com/harshgMSFT","followers_url":"https://api.github.com/users/harshgMSFT/followers","following_url":"https://api.github.com/users/harshgMSFT/following{/other_user}","gists_url":"https://api.github.com/users/harshgMSFT/gists{/gist_id}","starred_url":"https://api.github.com/users/harshgMSFT/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/harshgMSFT/subscriptions","organizations_url":"https://api.github.com/users/harshgMSFT/orgs","repos_url":"https://api.github.com/users/harshgMSFT/repos","events_url":"https://api.github.com/users/harshgMSFT/events{/privacy}","received_events_url":"https://api.github.com/users/harshgMSFT/received_events","type":"User","site_admin":false},"body":"Also adds tests for the same.\r\n\r\ncc: @Eilon , @lodejard , @davidfowl , @Praburaj ","created_at":"2015-02-25T21:49:30Z","updated_at":"2015-03-01T11:27:25Z","closed_at":null,"merged_at":null,"merge_commit_sha":"5dd5bc80969380bfff3d22eb8d7851040bb6d2b0","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/aspnet/CORS/pulls/3/commits","review_comments_url":"https://api.github.com/repos/aspnet/CORS/pulls/3/comments","review_comment_url":"https://api.github.com/repos/aspnet/CORS/pulls/comments{/number}","comments_url":"https://api.github.com/repos/aspnet/CORS/issues/3/comments","statuses_url":"https://api.github.com/repos/aspnet/CORS/statuses/e61a11e0128e93fbd717c02fde26a926a2b04841","head":{"label":"aspnet:feature-MVC","ref":"feature-MVC","sha":"e61a11e0128e93fbd717c02fde26a926a2b04841","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":30898960,"name":"CORS","full_name":"aspnet/CORS","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/CORS","description":"Implementations of common CORS policy and CORS middleware","fork":false,"url":"https://api.github.com/repos/aspnet/CORS","forks_url":"https://api.github.com/repos/aspnet/CORS/forks","keys_url":"https://api.github.com/repos/aspnet/CORS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/CORS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/CORS/teams","hooks_url":"https://api.github.com/repos/aspnet/CORS/hooks","issue_events_url":"https://api.github.com/repos/aspnet/CORS/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/CORS/events","assignees_url":"https://api.github.com/repos/aspnet/CORS/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/CORS/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/CORS/tags","blobs_url":"https://api.github.com/repos/aspnet/CORS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/CORS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/CORS/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/CORS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/CORS/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/CORS/languages","stargazers_url":"https://api.github.com/repos/aspnet/CORS/stargazers","contributors_url":"https://api.github.com/repos/aspnet/CORS/contributors","subscribers_url":"https://api.github.com/repos/aspnet/CORS/subscribers","subscription_url":"https://api.github.com/repos/aspnet/CORS/subscription","commits_url":"https://api.github.com/repos/aspnet/CORS/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/CORS/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/CORS/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/CORS/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/CORS/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/CORS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/CORS/merges","archive_url":"https://api.github.com/repos/aspnet/CORS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/CORS/downloads","issues_url":"https://api.github.com/repos/aspnet/CORS/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/CORS/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/CORS/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/CORS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/CORS/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/CORS/releases{/id}","created_at":"2015-02-17T02:17:36Z","updated_at":"2015-02-27T13:20:20Z","pushed_at":"2015-02-27T06:07:04Z","git_url":"git://github.com/aspnet/CORS.git","ssh_url":"git@github.com:aspnet/CORS.git","clone_url":"https://github.com/aspnet/CORS.git","svn_url":"https://github.com/aspnet/CORS","homepage":null,"size":388,"stargazers_count":3,"watchers_count":3,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"dev"}},"base":{"label":"aspnet:dev","ref":"dev","sha":"594ccb98ccb67b2c33f0c32d0cf13186f7e8578a","user":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"repo":{"id":30898960,"name":"CORS","full_name":"aspnet/CORS","owner":{"login":"aspnet","id":6476660,"avatar_url":"https://avatars.githubusercontent.com/u/6476660?v=3","gravatar_id":"","url":"https://api.github.com/users/aspnet","html_url":"https://github.com/aspnet","followers_url":"https://api.github.com/users/aspnet/followers","following_url":"https://api.github.com/users/aspnet/following{/other_user}","gists_url":"https://api.github.com/users/aspnet/gists{/gist_id}","starred_url":"https://api.github.com/users/aspnet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aspnet/subscriptions","organizations_url":"https://api.github.com/users/aspnet/orgs","repos_url":"https://api.github.com/users/aspnet/repos","events_url":"https://api.github.com/users/aspnet/events{/privacy}","received_events_url":"https://api.github.com/users/aspnet/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/aspnet/CORS","description":"Implementations of common CORS policy and CORS middleware","fork":false,"url":"https://api.github.com/repos/aspnet/CORS","forks_url":"https://api.github.com/repos/aspnet/CORS/forks","keys_url":"https://api.github.com/repos/aspnet/CORS/keys{/key_id}","collaborators_url":"https://api.github.com/repos/aspnet/CORS/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/aspnet/CORS/teams","hooks_url":"https://api.github.com/repos/aspnet/CORS/hooks","issue_events_url":"https://api.github.com/repos/aspnet/CORS/issues/events{/number}","events_url":"https://api.github.com/repos/aspnet/CORS/events","assignees_url":"https://api.github.com/repos/aspnet/CORS/assignees{/user}","branches_url":"https://api.github.com/repos/aspnet/CORS/branches{/branch}","tags_url":"https://api.github.com/repos/aspnet/CORS/tags","blobs_url":"https://api.github.com/repos/aspnet/CORS/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/aspnet/CORS/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/aspnet/CORS/git/refs{/sha}","trees_url":"https://api.github.com/repos/aspnet/CORS/git/trees{/sha}","statuses_url":"https://api.github.com/repos/aspnet/CORS/statuses/{sha}","languages_url":"https://api.github.com/repos/aspnet/CORS/languages","stargazers_url":"https://api.github.com/repos/aspnet/CORS/stargazers","contributors_url":"https://api.github.com/repos/aspnet/CORS/contributors","subscribers_url":"https://api.github.com/repos/aspnet/CORS/subscribers","subscription_url":"https://api.github.com/repos/aspnet/CORS/subscription","commits_url":"https://api.github.com/repos/aspnet/CORS/commits{/sha}","git_commits_url":"https://api.github.com/repos/aspnet/CORS/git/commits{/sha}","comments_url":"https://api.github.com/repos/aspnet/CORS/comments{/number}","issue_comment_url":"https://api.github.com/repos/aspnet/CORS/issues/comments{/number}","contents_url":"https://api.github.com/repos/aspnet/CORS/contents/{+path}","compare_url":"https://api.github.com/repos/aspnet/CORS/compare/{base}...{head}","merges_url":"https://api.github.com/repos/aspnet/CORS/merges","archive_url":"https://api.github.com/repos/aspnet/CORS/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/aspnet/CORS/downloads","issues_url":"https://api.github.com/repos/aspnet/CORS/issues{/number}","pulls_url":"https://api.github.com/repos/aspnet/CORS/pulls{/number}","milestones_url":"https://api.github.com/repos/aspnet/CORS/milestones{/number}","notifications_url":"https://api.github.com/repos/aspnet/CORS/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/aspnet/CORS/labels{/name}","releases_url":"https://api.github.com/repos/aspnet/CORS/releases{/id}","created_at":"2015-02-17T02:17:36Z","updated_at":"2015-02-27T13:20:20Z","pushed_at":"2015-02-27T06:07:04Z","git_url":"git://github.com/aspnet/CORS.git","ssh_url":"git@github.com:aspnet/CORS.git","clone_url":"https://github.com/aspnet/CORS.git","svn_url":"https://github.com/aspnet/CORS","homepage":null,"size":388,"stargazers_count":3,"watchers_count":3,"language":"Shell","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":2,"forks":0,"open_issues":2,"watchers":3,"default_branch":"dev"}},"_links":{"self":{"href":"https://api.github.com/repos/aspnet/CORS/pulls/3"},"html":{"href":"https://github.com/aspnet/CORS/pull/3"},"issue":{"href":"https://api.github.com/repos/aspnet/CORS/issues/3"},"comments":{"href":"https://api.github.com/repos/aspnet/CORS/issues/3/comments"},"review_comments":{"href":"https://api.github.com/repos/aspnet/CORS/pulls/3/comments"},"review_comment":{"href":"https://api.github.com/repos/aspnet/CORS/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/aspnet/CORS/pulls/3/commits"},"statuses":{"href":"https://api.github.com/repos/aspnet/CORS/statuses/e61a11e0128e93fbd717c02fde26a926a2b04841"}}}}