Using a plug from a library(Crawly) with Phoenix

Hi, Im trying to use a Plug from Crawly to show its management UI

as per Crawly docs, it needs to be defined like this

defmodule MyApp.Router do
  use Plug.Router

  ...
  forward "/admin", Crawly.API.Router
  ...
end

so i did this in my phoenix app like follows

defmodule BookCrawlerWeb.Router do
  use BookCrawlerWeb, :router

  scope "/", BookCrawlerWeb do
    pipe_through :browser

    get "/", PageController, :home
    forward "/admin", Crawly.API.Router # Warn: BookCrawlerWeb.Crawly.API.Router is not available or is yet to be defined
  end
end

im getting following error
BookCrawlerWeb.Crawly.API.Router is not available or is yet to be defined

this file is clearly defined by Crawly but phoenix fails to find it :confused:

It was an issue with scope

  scope "/admin" do
    pipe_through :browser

    forward "/", Crawly.API.Router
  end

did the trick

1 Like