   methodMatches = (m) ->
     (m.HTTPMethod is $routeParams.method) and ((m.URI or '/') is $routeParams.servicePath)
 
-  initMethod = (m) ->
-    m.active = true
-    m.results ?= []
-    body = m.body?[0]
-    m.bodyContentType = body?.contentType
-    m.content = body?.example
-
   methodWatch = (s) ->
     {HTTPMethod, URI} = s.currentMethod
     HTTPMethod + URI

  $scope.hasParams = -> Object.keys($scope.params).length > 0
  $scope.parsedData = []
  $scope.tree = expanded: false

  ct = ($scope.headers['content-type'] ? '')
  promises = []
  if $scope.res.response?.length
    if ct.match(/^application\/json/)
      parsed = try
        JSON.parse($scope.res.response)
      catch e
        {}
      for k, v of parsed
        promises.push TreeParsing.parseObj k, v
    else if /^text\/xml/.test(ct) or /^application\/xml/.test(ct)
      try
        dom = xmlParser.parse $scope.res.response
        promises.push TreeParsing.parseDOMElem(dom.documentElement)
      catch e
        $log.error 'Error parsing xml', e

  setTree = (tree) ->
    $scope.parsedData = tree
    $log.debug "Next id = #{ TreeParsing.nextId() }"

  if promises.length
    $q.all(promises)
      .then((parsed) -> TreeParsing.expandTree parsed, not $scope.tree.expanded)
      .then setTree, $log.error

  $scope.isHTML = -> !!ct?.match /^text\/html/

  processingInstructions = /<\?[^?]*\?>/g
  $scope.cleanHTML = $scope.res.response.replace(processingInstructions, '')

    else
      []

  uniq = (things) ->
    index = {}
    for thing in things
      index[thing] = 1
    return Object.keys(index)

  $scope.suggest = (vv) ->
    term = String(vv).toLowerCase()
    if $scope.parameter.Options
      # Not sure why I had to implement filtering logic here...
      filter = (s) -> 0 <= String(s).toLowerCase().indexOf term
      return Suggestions.getSuggestions($scope.params, $scope.parameter)
                        .then( (sgs) -> sgs.filter filter )
                        .then( uniq )
    else
      d = $q.defer()
      d.resolve getHistory()
