Skip to content

Commit

Permalink
Tiny fixes for Crawly Rest API (#239)
Browse files Browse the repository at this point in the history
  • Loading branch information
oltarasenko committed Mar 8, 2023
1 parent 9eb23e1 commit c0bb487
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/crawly/api.ex
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ defmodule Crawly.API.Router do
get "/spiders" do
msg =
case Crawly.Engine.running_spiders() do
%{} ->
spiders when map_size(spiders) == 0 ->
"No spiders are currently running"

spiders ->
Expand Down Expand Up @@ -41,7 +41,7 @@ defmodule Crawly.API.Router do

msg =
case result do
{:error, :not_found} -> "Not found"
{:error, :spider_not_found} -> "Not found"
{:error, :spider_not_running} -> "Spider is not running"
:ok -> "Stopped!"
end
Expand All @@ -63,7 +63,7 @@ defmodule Crawly.API.Router do
end

get "/spiders/:spider_name/scraped-items" do
spider_name = String.to_atom("Elixir.#{spider_name}")
spider_name = String.to_existing_atom("Elixir.#{spider_name}")
result = Crawly.DataStorage.stats(spider_name)

msg =
Expand All @@ -76,6 +76,6 @@ defmodule Crawly.API.Router do
end

match _ do
send_resp(conn, 404, "Oops!")
send_resp(conn, 404, "Oops! Page not found!")
end
end

0 comments on commit c0bb487

Please sign in to comment.