mirror of https://github.com/inhji/plug_micropub
add category query
This commit is contained in:
parent
a63d32c00b
commit
1845a40677
|
@ -122,7 +122,7 @@ defmodule PlugMicropub do
|
|||
|
||||
defp get_query(conn) do
|
||||
case Map.fetch(conn.query_params, "q") do
|
||||
{:ok, query} when query in ["config", "source", "syndicate-to", "channel"] ->
|
||||
{:ok, query} when query in ["config", "source", "syndicate-to", "channel", "category"] ->
|
||||
{:ok, String.to_existing_atom(query)}
|
||||
|
||||
_ ->
|
||||
|
@ -200,6 +200,15 @@ defmodule PlugMicropub do
|
|||
end
|
||||
end
|
||||
|
||||
defp handle_query(:category, access_token, conn) do
|
||||
handler = conn.private[:plug_micropub][:handler]
|
||||
|
||||
case handler.handle_category_query(access_token) do
|
||||
{:ok, content} -> send_content(conn, content)
|
||||
error -> send_error(conn, error)
|
||||
end
|
||||
end
|
||||
|
||||
defp handle_query(:source, access_token, conn) do
|
||||
with {:ok, url} <- Map.fetch(conn.query_params, "url"),
|
||||
do: do_source_query(conn, access_token, url),
|
||||
|
|
|
@ -56,6 +56,10 @@ defmodule PlugMicropub.HandlerBehaviour do
|
|||
{:ok, map}
|
||||
| handler_error
|
||||
|
||||
@callback handle_category_query(access_token) ::
|
||||
{:ok, map}
|
||||
| handler_error
|
||||
|
||||
@callback handle_media(file :: Plug.Upload.t(), access_token) ::
|
||||
{:ok, url :: String.t()} | handler_error
|
||||
end
|
||||
|
|
Loading…
Reference in New Issue