First of all, thank you all for joining this saga for emulating file hosting in Phoenix.
For those who’re new, I’m trying to add a simple file browsing and download service (limited to json files); I can’t use database function for that thanks to “hard requirements”; I can’t use ecto for that.
I created a small custom struct for users to view invoices by struct than a full ecto schema; I can’t use user_json.ex to render my JSON output.
Anyway, here’s my controller to view one JSON file
def show_invoice(conn, %{“invoice_name” => invoice_name}) do
{:ok, invoice_json} = File.read("invoices/#{invoice_name}")
send_resp(conn, :ok, "#{invoice_json}")
end
I checked that invoice_json gives result in IO.inspect.
send_resp sends back 200 ok in my client but the body #{invoice_json} doesn’t render.
How to solve?