-1

I have this elixir module:

defmodule MyApp.Router do
  use Plug.Router

  plug :match
  plug :dispatch

  get "/" do
    send_resp(conn, 200, "Hello, World!")
  end
end

I run mix compile --no-halt and I get:

% mix run --no-halt

===> Analyzing applications... ===> Compiling cowboy_telemetry ==> plug_cowboy Compiling 5 files (.ex) warning: Logger.warn/1 is deprecated. Use Logger.warning/2 instead lib/plug/cowboy.ex:352: Plug.Cowboy.to_args/5

Generated plug_cowboy app ==> myapp Compiling 2 files (.ex) error: undefined function router/2 (expected MyApp.Endpoint to define such a function or for it to be imported, but none are available) lib/my_app/endpoint.ex:1: MyApp.Endpoint.plug_builder_call/2

== Compilation error in file lib/my_app/endpoint.ex == ** (CompileError) lib/my_app/endpoint.ex: cannot compile module MyApp.Endpoint (errors have been logged)

I have no idea what this error means, my mix.exs file is like:

defmodule My.Api.MixProject do
  use Mix.Project

  def project do
    [
      app: :myapp,
      version: "0.1.0",
      elixir: "~> 1.15",
      start_permanent: Mix.env() == :prod,
      deps: deps()
    ]
  end

 
  def application do
    [
      extra_applications: [:logger],
      mod: {MyApp.Endpoint, []}
    ]
  end

 
  defp deps do
    [
      {:plug_cowboy, "~> 2.6"},
      {:cowboy, "~> 2.10"},
      {:plug, "~> 1.12"}

    ]
  end
end
General Grievance
  • 4,555
  • 31
  • 31
  • 45
Alexander Mills
  • 90,741
  • 139
  • 482
  • 817
  • 4
    What's in `lib/my_app/endpoint.ex`? From the error message it looks like the error is in that file. – Dogbert Aug 03 '23 at 19:38
  • Agreeing with the comment above. Do you plug your `MyApp.Router` in `lib/my_app/endpoint.ex` ? – jakobfp Aug 30 '23 at 06:51

0 Answers0