Skip to content

Commit

Permalink
Merge branch 'master' into gen_spider
Browse files Browse the repository at this point in the history
  • Loading branch information
oltarasenko committed Mar 8, 2023
2 parents 4bbf3c7 + c0bb487 commit 285dc57
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions lib/crawly/api.ex
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 285dc57

Please sign in to comment.