Created
June 30, 2015 14:42
-
-
Save alanpeabody/b507575415e22a4a0ea3 to your computer and use it in GitHub Desktop.
dev_code_reload_plug.ex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Reload/recompile code before each request in development only using Plug & Mix. | |
# Assumes MyApp.Router is a plug that handles actual routing. | |
def MyApp.Main do | |
use Plug.Builder | |
plug :reload | |
plug :dispatch | |
def reload(conn, _opts) do | |
if Mix.env == :dev, do: Mix.Tasks.Compile.Elixir.run(["--ignore-module-conflict"]) | |
conn | |
end | |
def dispatch(conn, opts), do: MyApp.Router.call(conn, opts) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment