Closed YellowApple closed 9 years ago
Content of lib/yellowapple_site/router.ex
, for reference (doesn't deviate a whole lot from the defaults):
defmodule YellowappleSite.Router do
use Sugar.Router
plug Sugar.Plugs.HotCodeReload
if Sugar.Config.get(:sugar, :show_debugger, false) do
plug Plug.Debugger, otp_app: :your_project
end
plug Plug.Static, at: "/static", from: :yellowapple_site
get "/", YellowappleSite.Controllers.Main, :index
end
And here's config/config.exs
:
use Mix.Config
config :sugar, router: YellowappleSite.Router
config :sugar, YellowappleSite.Router, https_only: false, https: false, http: [
port: 4000
]
@YellowApple I'd have to say that the switch to HttpRouter is the cause, but I'm not sure yet why. The run
function should be available thanks to the definition in the __before_compile__/1
macro. I'll dig around and try to figure out what's up.
That's what I figure, too; the run
function definition in that macro didn't change at all during the switch to HttpRouter (at least according to the commit diffs), so it should work at least as well as it did before (at least at that point).
For what it's worth, the dirty hack of copying run
's definition into lib/yellowapple_site/router.ex
makes everything work correctly, even with HttpRouter. So it's definitely something going on with that macro, but why it would suddenly be a problem now is an unanswered question.
Aaaaand ficks'd.
Turns out we just needed to actually use that macro definition in the __using__
macro; shoving @before_compile Sugar.Router
after the use HttpRouter, ...
clause fixed everything (at least in my simple hello-world-style app).
Nice job! I was driving to work and remembered that the @before_compile
line wasn't there anymore, so I'm glad you figured it out as well. :thumbsup:
Full error:
This code works fine with Sugar 0.4.3, which indicates (to me at least) that for some reason moving to HttpRouter broke things, and I've yet to figure out why, though my hunch is that there's some confusion about
run
's arity. Thoughts on this?