   end
 
   @authentication_error_json JSX.encode!(%{error: "Authentication error"})
-  # http://pusher.com/docs/rest_api#authentication
+
+  @doc """
+  More info http://pusher.com/docs/rest_api#authentication
+  """
   def is_authorized(req, %{body: body} = state) do
     {qs_vals, req} = :cowboy_req.qs_vals(req)
     {method, req} = :cowboy_req.method(req)

    {valid, req, state}
  end

  def content_types_accepted(req, state) do
    {[{{"application", "json", :*}, :post}], req, state}
  end

  def content_types_provided(req, state) do
    {[{{"application", "json", []}, :undefined}], req, state}
  end

  def post(req, %{event: event}) do
    PusherEvent.publish(event)
    Event.notify(:api_message, %{channels: event.channels, name: event.name})

  alias Poxa.Event
  require Logger

  @doc false
  def init(_transport, _req, _opts), do: {:upgrade, :protocol, :cowboy_rest}

  def allowed_methods(req, state), do: {["POST"], req, state}

  @invalid_event_json JSX.encode!(%{error: "Event must have channel(s), name, and data"})

  @doc """
  If the body is not JSON or not a valid PusherEvent this function will
  guarantee that 400 will be returned
  """
  def malformed_request(req, state) do
    {:ok, body, req} = :cowboy_req.body(req)
    case JSX.decode(body) do
