{"action":"created","comment":{"url":"https://api.github.com/repos/rackerlabs/api-checker/pulls/comments/25123748","id":25123748,"diff_hunk":"@@ -0,0 +1,54 @@\n+/** *\n+  * Copyright 2014 Rackspace US, Inc.\n+  *\n+  * Licensed under the Apache License, Version 2.0 (the \"License\");\n+  * you may not use this file except in compliance with the License.\n+  * You may obtain a copy of the License at\n+  *\n+  * http://www.apache.org/licenses/LICENSE-2.0\n+  *\n+  * Unless required by applicable law or agreed to in writing, software\n+  * distributed under the License is distributed on an \"AS IS\" BASIS,\n+  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n+  * See the License for the specific language governing permissions and\n+  * limitations under the License.\n+  */\n+\n+package com.rackspace.com.papi.components.checker.handler\n+\n+import javax.servlet.FilterChain\n+\n+import com.rackspace.com.papi.components.checker.Validator\n+import com.rackspace.com.papi.components.checker.servlet.{CheckerServletRequest, CheckerServletResponse}\n+import com.rackspace.com.papi.components.checker.step.{StepContext, Step, Result}\n+import org.w3c.dom.{Document, NodeList}\n+\n+class MethodLabelHandler extends ResultHandler  {\n+  val MethodLabelHeaderName: String = \"X-METHOD-LABEL\"\n+\n+  var methodMap : Map[String, String] = Map()\n+\n+  override def init(validator: Validator, checker: Option[Document]): Unit = {\n+    checker.map { doc =>\n+      val steps: NodeList = doc.getElementsByTagName(\"step\")\n+      for {\n+        i <- 0 until steps.getLength\n+        item <- Option(steps.item(i))\n+        attributes <- Option(item.getAttributes)\n+        attType <- Option(attributes.getNamedItem(\"type\"))\n+        id <- Option(attributes.getNamedItem(\"id\")) if \"METHOD\".equalsIgnoreCase(attType.getTextContent)\n+        label <- Option(attributes.getNamedItem(\"label\")) if \"METHOD\".equalsIgnoreCase(attType.getTextContent)\n+        idText <- Option(id.getTextContent)\n+        labelText <- Option(label.getTextContent)\n+      } yield {\n+        methodMap = methodMap ++ Map(idText -> labelText)\n+      }\n+    }\n+  }\n+\n+  override def handle(req: CheckerServletRequest, resp: CheckerServletResponse, chain: FilterChain, result: Result): Unit = {}\n+\n+  override def inStep (currentStep: Step, req: CheckerServletRequest, resp : CheckerServletResponse, context: StepContext) : Unit = {\n+    methodMap.get(currentStep.id).map(req.addHeader(\"X-METHOD-LABEL\",_))","path":"core/src/main/scala/handler/MethodLabelHandler.scala","position":52,"original_position":52,"commit_id":"5aa6b423e8e298d7b6813292101c3ad37304bcd2","original_commit_id":"5aa6b423e8e298d7b6813292101c3ad37304bcd2","user":{"login":"RackerWilliams","id":348314,"avatar_url":"https://avatars.githubusercontent.com/u/348314?v=3","gravatar_id":"","url":"https://api.github.com/users/RackerWilliams","html_url":"https://github.com/RackerWilliams","followers_url":"https://api.github.com/users/RackerWilliams/followers","following_url":"https://api.github.com/users/RackerWilliams/following{/other_user}","gists_url":"https://api.github.com/users/RackerWilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/RackerWilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RackerWilliams/subscriptions","organizations_url":"https://api.github.com/users/RackerWilliams/orgs","repos_url":"https://api.github.com/users/RackerWilliams/repos","events_url":"https://api.github.com/users/RackerWilliams/events{/privacy}","received_events_url":"https://api.github.com/users/RackerWilliams/received_events","type":"User","site_admin":false},"body":"This won't work 😞\r\n\r\nYou'll end up setting multiple headers in some cases.  The reason for this is that it is possible for a resource to have multiple ```POST``` methods each with its own label.  There are a lot of examples of this....the easiest one to explain is Atom Hopper.  You can POST a load balancer create message or you can POST a load balancer delete message to the same feed  -- what sets the methods apart is a property of the content which is checked *after* the method is checked.\r\n\r\nInstead of adding a header, you should create a new context with the result header.  If the path isn't followed trough -- that context will pop out of the stack. ","created_at":"2015-02-21T17:23:44Z","updated_at":"2015-02-21T17:23:44Z","html_url":"https://github.com/rackerlabs/api-checker/pull/242#discussion_r25123748","pull_request_url":"https://api.github.com/repos/rackerlabs/api-checker/pulls/242","_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/api-checker/pulls/comments/25123748"},"html":{"href":"https://github.com/rackerlabs/api-checker/pull/242#discussion_r25123748"},"pull_request":{"href":"https://api.github.com/repos/rackerlabs/api-checker/pulls/242"}}},"pull_request":{"url":"https://api.github.com/repos/rackerlabs/api-checker/pulls/242","id":28942403,"html_url":"https://github.com/rackerlabs/api-checker/pull/242","diff_url":"https://github.com/rackerlabs/api-checker/pull/242.diff","patch_url":"https://github.com/rackerlabs/api-checker/pull/242.patch","issue_url":"https://api.github.com/repos/rackerlabs/api-checker/issues/242","number":242,"state":"open","locked":false,"title":"created method label handler to return a header with the method label if...","user":{"login":"tylerroyal","id":3344417,"avatar_url":"https://avatars.githubusercontent.com/u/3344417?v=3","gravatar_id":"","url":"https://api.github.com/users/tylerroyal","html_url":"https://github.com/tylerroyal","followers_url":"https://api.github.com/users/tylerroyal/followers","following_url":"https://api.github.com/users/tylerroyal/following{/other_user}","gists_url":"https://api.github.com/users/tylerroyal/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerroyal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerroyal/subscriptions","organizations_url":"https://api.github.com/users/tylerroyal/orgs","repos_url":"https://api.github.com/users/tylerroyal/repos","events_url":"https://api.github.com/users/tylerroyal/events{/privacy}","received_events_url":"https://api.github.com/users/tylerroyal/received_events","type":"User","site_admin":false},"body":"... it is available in the stepID list","created_at":"2015-02-09T18:02:12Z","updated_at":"2015-02-21T17:23:44Z","closed_at":null,"merged_at":null,"merge_commit_sha":"edafef1848cfe72f9c3424ed751f9e9bfaeaa72f","assignee":null,"milestone":{"url":"https://api.github.com/repos/rackerlabs/api-checker/milestones/27","labels_url":"https://api.github.com/repos/rackerlabs/api-checker/milestones/27/labels","id":942696,"number":27,"title":"1.0.22","description":"","creator":{"login":"RackerWilliams","id":348314,"avatar_url":"https://avatars.githubusercontent.com/u/348314?v=3","gravatar_id":"","url":"https://api.github.com/users/RackerWilliams","html_url":"https://github.com/RackerWilliams","followers_url":"https://api.github.com/users/RackerWilliams/followers","following_url":"https://api.github.com/users/RackerWilliams/following{/other_user}","gists_url":"https://api.github.com/users/RackerWilliams/gists{/gist_id}","starred_url":"https://api.github.com/users/RackerWilliams/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/RackerWilliams/subscriptions","organizations_url":"https://api.github.com/users/RackerWilliams/orgs","repos_url":"https://api.github.com/users/RackerWilliams/repos","events_url":"https://api.github.com/users/RackerWilliams/events{/privacy}","received_events_url":"https://api.github.com/users/RackerWilliams/received_events","type":"User","site_admin":false},"open_issues":8,"closed_issues":1,"state":"open","created_at":"2015-01-19T22:31:30Z","updated_at":"2015-02-18T02:16:31Z","due_on":"2015-02-28T06:00:00Z","closed_at":null},"commits_url":"https://api.github.com/repos/rackerlabs/api-checker/pulls/242/commits","review_comments_url":"https://api.github.com/repos/rackerlabs/api-checker/pulls/242/comments","review_comment_url":"https://api.github.com/repos/rackerlabs/api-checker/pulls/comments/{number}","comments_url":"https://api.github.com/repos/rackerlabs/api-checker/issues/242/comments","statuses_url":"https://api.github.com/repos/rackerlabs/api-checker/statuses/5aa6b423e8e298d7b6813292101c3ad37304bcd2","head":{"label":"tylerroyal:method-label-handler","ref":"method-label-handler","sha":"5aa6b423e8e298d7b6813292101c3ad37304bcd2","user":{"login":"tylerroyal","id":3344417,"avatar_url":"https://avatars.githubusercontent.com/u/3344417?v=3","gravatar_id":"","url":"https://api.github.com/users/tylerroyal","html_url":"https://github.com/tylerroyal","followers_url":"https://api.github.com/users/tylerroyal/followers","following_url":"https://api.github.com/users/tylerroyal/following{/other_user}","gists_url":"https://api.github.com/users/tylerroyal/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerroyal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerroyal/subscriptions","organizations_url":"https://api.github.com/users/tylerroyal/orgs","repos_url":"https://api.github.com/users/tylerroyal/repos","events_url":"https://api.github.com/users/tylerroyal/events{/privacy}","received_events_url":"https://api.github.com/users/tylerroyal/received_events","type":"User","site_admin":false},"repo":{"id":27384840,"name":"api-checker","full_name":"tylerroyal/api-checker","owner":{"login":"tylerroyal","id":3344417,"avatar_url":"https://avatars.githubusercontent.com/u/3344417?v=3","gravatar_id":"","url":"https://api.github.com/users/tylerroyal","html_url":"https://github.com/tylerroyal","followers_url":"https://api.github.com/users/tylerroyal/followers","following_url":"https://api.github.com/users/tylerroyal/following{/other_user}","gists_url":"https://api.github.com/users/tylerroyal/gists{/gist_id}","starred_url":"https://api.github.com/users/tylerroyal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/tylerroyal/subscriptions","organizations_url":"https://api.github.com/users/tylerroyal/orgs","repos_url":"https://api.github.com/users/tylerroyal/repos","events_url":"https://api.github.com/users/tylerroyal/events{/privacy}","received_events_url":"https://api.github.com/users/tylerroyal/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/tylerroyal/api-checker","description":"The API Checker library allows checking a rest servlet against a contract written in WADL","fork":true,"url":"https://api.github.com/repos/tylerroyal/api-checker","forks_url":"https://api.github.com/repos/tylerroyal/api-checker/forks","keys_url":"https://api.github.com/repos/tylerroyal/api-checker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/tylerroyal/api-checker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/tylerroyal/api-checker/teams","hooks_url":"https://api.github.com/repos/tylerroyal/api-checker/hooks","issue_events_url":"https://api.github.com/repos/tylerroyal/api-checker/issues/events{/number}","events_url":"https://api.github.com/repos/tylerroyal/api-checker/events","assignees_url":"https://api.github.com/repos/tylerroyal/api-checker/assignees{/user}","branches_url":"https://api.github.com/repos/tylerroyal/api-checker/branches{/branch}","tags_url":"https://api.github.com/repos/tylerroyal/api-checker/tags","blobs_url":"https://api.github.com/repos/tylerroyal/api-checker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/tylerroyal/api-checker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/tylerroyal/api-checker/git/refs{/sha}","trees_url":"https://api.github.com/repos/tylerroyal/api-checker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/tylerroyal/api-checker/statuses/{sha}","languages_url":"https://api.github.com/repos/tylerroyal/api-checker/languages","stargazers_url":"https://api.github.com/repos/tylerroyal/api-checker/stargazers","contributors_url":"https://api.github.com/repos/tylerroyal/api-checker/contributors","subscribers_url":"https://api.github.com/repos/tylerroyal/api-checker/subscribers","subscription_url":"https://api.github.com/repos/tylerroyal/api-checker/subscription","commits_url":"https://api.github.com/repos/tylerroyal/api-checker/commits{/sha}","git_commits_url":"https://api.github.com/repos/tylerroyal/api-checker/git/commits{/sha}","comments_url":"https://api.github.com/repos/tylerroyal/api-checker/comments{/number}","issue_comment_url":"https://api.github.com/repos/tylerroyal/api-checker/issues/comments/{number}","contents_url":"https://api.github.com/repos/tylerroyal/api-checker/contents/{+path}","compare_url":"https://api.github.com/repos/tylerroyal/api-checker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/tylerroyal/api-checker/merges","archive_url":"https://api.github.com/repos/tylerroyal/api-checker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/tylerroyal/api-checker/downloads","issues_url":"https://api.github.com/repos/tylerroyal/api-checker/issues{/number}","pulls_url":"https://api.github.com/repos/tylerroyal/api-checker/pulls{/number}","milestones_url":"https://api.github.com/repos/tylerroyal/api-checker/milestones{/number}","notifications_url":"https://api.github.com/repos/tylerroyal/api-checker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/tylerroyal/api-checker/labels{/name}","releases_url":"https://api.github.com/repos/tylerroyal/api-checker/releases{/id}","created_at":"2014-12-01T15:12:36Z","updated_at":"2015-02-18T16:03:14Z","pushed_at":"2015-02-20T22:33:13Z","git_url":"git://github.com/tylerroyal/api-checker.git","ssh_url":"git@github.com:tylerroyal/api-checker.git","clone_url":"https://github.com/tylerroyal/api-checker.git","svn_url":"https://github.com/tylerroyal/api-checker","homepage":"www.openrepose.org","size":3374,"stargazers_count":0,"watchers_count":0,"language":"Scala","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":"rackerlabs:master","ref":"master","sha":"4ff602b11abc942174791aaf3238eba37143fc39","user":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"repo":{"id":3188519,"name":"api-checker","full_name":"rackerlabs/api-checker","owner":{"login":"rackerlabs","id":84293,"avatar_url":"https://avatars.githubusercontent.com/u/84293?v=3","gravatar_id":"","url":"https://api.github.com/users/rackerlabs","html_url":"https://github.com/rackerlabs","followers_url":"https://api.github.com/users/rackerlabs/followers","following_url":"https://api.github.com/users/rackerlabs/following{/other_user}","gists_url":"https://api.github.com/users/rackerlabs/gists{/gist_id}","starred_url":"https://api.github.com/users/rackerlabs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/rackerlabs/subscriptions","organizations_url":"https://api.github.com/users/rackerlabs/orgs","repos_url":"https://api.github.com/users/rackerlabs/repos","events_url":"https://api.github.com/users/rackerlabs/events{/privacy}","received_events_url":"https://api.github.com/users/rackerlabs/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/rackerlabs/api-checker","description":"The API Checker library allows checking a rest servlet against a contract written in WADL","fork":false,"url":"https://api.github.com/repos/rackerlabs/api-checker","forks_url":"https://api.github.com/repos/rackerlabs/api-checker/forks","keys_url":"https://api.github.com/repos/rackerlabs/api-checker/keys{/key_id}","collaborators_url":"https://api.github.com/repos/rackerlabs/api-checker/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/rackerlabs/api-checker/teams","hooks_url":"https://api.github.com/repos/rackerlabs/api-checker/hooks","issue_events_url":"https://api.github.com/repos/rackerlabs/api-checker/issues/events{/number}","events_url":"https://api.github.com/repos/rackerlabs/api-checker/events","assignees_url":"https://api.github.com/repos/rackerlabs/api-checker/assignees{/user}","branches_url":"https://api.github.com/repos/rackerlabs/api-checker/branches{/branch}","tags_url":"https://api.github.com/repos/rackerlabs/api-checker/tags","blobs_url":"https://api.github.com/repos/rackerlabs/api-checker/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/rackerlabs/api-checker/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/rackerlabs/api-checker/git/refs{/sha}","trees_url":"https://api.github.com/repos/rackerlabs/api-checker/git/trees{/sha}","statuses_url":"https://api.github.com/repos/rackerlabs/api-checker/statuses/{sha}","languages_url":"https://api.github.com/repos/rackerlabs/api-checker/languages","stargazers_url":"https://api.github.com/repos/rackerlabs/api-checker/stargazers","contributors_url":"https://api.github.com/repos/rackerlabs/api-checker/contributors","subscribers_url":"https://api.github.com/repos/rackerlabs/api-checker/subscribers","subscription_url":"https://api.github.com/repos/rackerlabs/api-checker/subscription","commits_url":"https://api.github.com/repos/rackerlabs/api-checker/commits{/sha}","git_commits_url":"https://api.github.com/repos/rackerlabs/api-checker/git/commits{/sha}","comments_url":"https://api.github.com/repos/rackerlabs/api-checker/comments{/number}","issue_comment_url":"https://api.github.com/repos/rackerlabs/api-checker/issues/comments/{number}","contents_url":"https://api.github.com/repos/rackerlabs/api-checker/contents/{+path}","compare_url":"https://api.github.com/repos/rackerlabs/api-checker/compare/{base}...{head}","merges_url":"https://api.github.com/repos/rackerlabs/api-checker/merges","archive_url":"https://api.github.com/repos/rackerlabs/api-checker/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/rackerlabs/api-checker/downloads","issues_url":"https://api.github.com/repos/rackerlabs/api-checker/issues{/number}","pulls_url":"https://api.github.com/repos/rackerlabs/api-checker/pulls{/number}","milestones_url":"https://api.github.com/repos/rackerlabs/api-checker/milestones{/number}","notifications_url":"https://api.github.com/repos/rackerlabs/api-checker/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/rackerlabs/api-checker/labels{/name}","releases_url":"https://api.github.com/repos/rackerlabs/api-checker/releases{/id}","created_at":"2012-01-16T06:39:01Z","updated_at":"2015-02-17T18:16:12Z","pushed_at":"2015-02-17T16:44:34Z","git_url":"git://github.com/rackerlabs/api-checker.git","ssh_url":"git@github.com:rackerlabs/api-checker.git","clone_url":"https://github.com/rackerlabs/api-checker.git","svn_url":"https://github.com/rackerlabs/api-checker","homepage":"www.openrepose.org","size":4870,"stargazers_count":5,"watchers_count":5,"language":"Scala","has_issues":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":12,"mirror_url":null,"open_issues_count":32,"forks":12,"open_issues":32,"watchers":5,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/rackerlabs/api-checker/pulls/242"},"html":{"href":"https://github.com/rackerlabs/api-checker/pull/242"},"issue":{"href":"https://api.github.com/repos/rackerlabs/api-checker/issues/242"},"comments":{"href":"https://api.github.com/repos/rackerlabs/api-checker/issues/242/comments"},"review_comments":{"href":"https://api.github.com/repos/rackerlabs/api-checker/pulls/242/comments"},"review_comment":{"href":"https://api.github.com/repos/rackerlabs/api-checker/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/rackerlabs/api-checker/pulls/242/commits"},"statuses":{"href":"https://api.github.com/repos/rackerlabs/api-checker/statuses/5aa6b423e8e298d7b6813292101c3ad37304bcd2"}}}}