<commit_before>defmodule Sugar.Router do
  @moduledoc """
  `Sugar.Router` defines an alternate format for `Plug.Router` 
  routing. Supports all HTTP methods that `Plug.Router` supports,
  currently `get`, `post`, `put`, `patch`, `delete`, and `options`.

  ## Example

      defmodule Routes do
        use Sugar.Router

        get "/", Main, :index
        get "/pages/:slug", Page, :show
      end
  """

  ## Macros
  
  defmacro __using__(_) do
    quote do
      import unquote(__MODULE__)
      use Plug.Router
    end
  end

  defmacro get(route, controller, action) do
    quote do
      get unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn)])
        end
      )
    end
  end

  defmacro post(route, controller, action) do
    quote do
      post unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn)])
        end
      )
    end
  end

  defmacro put(route, controller, action) do
    quote do
      put unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn)])
        end
      )
    end
  end

  defmacro patch(route, controller, action) do
    quote do
      patch unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn)])
        end
      )
    end
  end

  defmacro delete(route, controller, action) do
    quote do
      delete unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn)])
        end
      )
    end
  end

  defmacro options(route, controller, action) do
    quote do
      options unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn)])
        end
      )
    end
  end

  defmacro any(route, controller, action) do
    quote do
      match unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn)])
        end
      )
    end
  end
end<commit_msg>update macros to pass inner binding<commit_after>defmodule Sugar.Router do
  @moduledoc """
  `Sugar.Router` defines an alternate format for `Plug.Router` 
  routing. Supports all HTTP methods that `Plug.Router` supports,
  currently `get`, `post`, `put`, `patch`, `delete`, and `options`.

  ## Example

      defmodule Routes do
        use Sugar.Router

        get "/", Main, :index
        get "/pages/:slug", Page, :show
      end
  """

  ## Macros
  
  defmacro __using__(_) do
    quote do
      import unquote(__MODULE__)
      use Plug.Router
    end
  end

  defmacro get(route, controller, action) do
    quote do
      get unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn), binding()])
        end
      )
    end
  end

  defmacro post(route, controller, action) do
    quote do
      post unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn), binding()])
        end
      )
    end
  end

  defmacro put(route, controller, action) do
    quote do
      put unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn), binding()])
        end
      )
    end
  end

  defmacro patch(route, controller, action) do
    quote do
      patch unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn), binding()])
        end
      )
    end
  end

  defmacro delete(route, controller, action) do
    quote do
      delete unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn), binding()])
        end
      )
    end
  end

  defmacro options(route, controller, action) do
    quote do
      options unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn), binding()])
        end
      )
    end
  end

  defmacro any(route, controller, action) do
    quote do
      match unquote(route), do: unquote(
        quote do 
          apply(unquote(controller), unquote(action), [var!(conn), binding()])
        end
      )
    end
  end
end
{'fraction_non_alphanumeric': 0.10971348707197764, 'fraction_numerical': 0.0, 'mean_word_length': 2.2456538170823883, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1261586', 'n_tokens_mistral': 1339, 'n_tokens_neox': 1279, 'n_words': 385}