What is the equivalent of 'head :ok' from Rails in Phoenix?

前端 未结 2 453
自闭症患者
自闭症患者 2021-01-17 11:14

I want to return a response that has no content (merely headers) like this one

def show
  head :ok
end
2条回答
  •  予麋鹿
    予麋鹿 (楼主)
    2021-01-17 11:29

    @dogbert answers was spot on. Additionally you can read up on relevant documentation from official phoenix guide. The relevant information - http://www.phoenixframework.org/docs/controllers#section-sending-responses-directly

    ...Let's say we want to send a response with a status of "201" and no body whatsoever. We can easily do that with the send_resp/3 function.

    def index(conn, _params) do
      conn
      |> send_resp(201, "")
    end
    

提交回复
热议问题