|
|
@ -10,6 +10,15 @@ defmodule LinkShortenerWeb.Api.V1.LinksController do
|
|
|
|
render(conn, "index.json", links: links)
|
|
|
|
render(conn, "index.json", links: links)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def create(conn, %{"link" => link_params}) do
|
|
|
|
|
|
|
|
with {:ok, %Links{} = link} <- Links.insert_one(link_params) do
|
|
|
|
|
|
|
|
conn
|
|
|
|
|
|
|
|
|> put_status(:created)
|
|
|
|
|
|
|
|
|> put_resp_header("location", Routes.links_path(conn, :show, link))
|
|
|
|
|
|
|
|
|> render("show.json", links: link)
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
|
|
def show(conn, %{"id" => id}) do
|
|
|
|
def show(conn, %{"id" => id}) do
|
|
|
|
link = Links.get_one(id)
|
|
|
|
link = Links.get_one(id)
|
|
|
|
render(conn, "show.json", links: link)
|
|
|
|
render(conn, "show.json", links: link)
|
|
|
|