dwyl / hits-elixir

:chart_with_upwards_trend: An Elixir implementation of the "Hits" project (a super-basic "Web Page View Counter")
http://hits.dwyl.io
GNU General Public License v2.0
31 stars 1 forks source link

Avoid Sending the Response *Twice* ... (Plug.Conn.AlreadySentError) the response was already sent #2

Closed nelsonic closed 7 years ago

nelsonic commented 7 years ago
16:36:11.245 [error] #PID<0.285.0> running App.Router terminated
Server: localhost:8080 (http)
Request: GET /upload
** (exit) an exception was raised:
    ** (Plug.Conn.AlreadySentError) the response was already sent
        (plug) lib/plug/conn.ex:499: Plug.Conn.resp/3
        (plug) lib/plug/conn.ex:486: Plug.Conn.send_resp/3
        (app) lib/router.ex:1: App.Router.plug_builder_call/2
        (plug) lib/plug/adapters/cowboy/handler.ex:15: Plug.Adapters.Cowboy.Handler.upgrade/4
        (cowboy) /dwyl/hits-elixir/deps/cowboy/src/cowboy_protocol.erl:442: :cowboy_protocol.execute/4
nelsonic commented 7 years ago

This is no longer an issue because I'm not using this plug. but it was solved by:

  def call(conn, opts) do
    conn
    |> put_resp_content_type("image/svg+xml")
    |> send_resp(200, make_badge(42))
    |> halt()
  end