Where do you put plugs in codebase?

I’m starting a new Phoenix 1.3 application and following along with the PragProg book for authentication. The book says to put auth.ex plug code into the controllers directory. Is that still the canonical directory to put plugs? That kind of makes sense to me but after years of rails development I fear a pollution of the controller directory with plugs over time. :slight_smile: Does the conventional wisdom for Phoenix 1.3 and the use of contexts change anything in this regard? I was wondering if putting auth.ex in my accounts directory (accounts being my context with users under it).

Thanks for any tips.

2 Likes

I put them in the lib/web/plugs folder.

3 Likes

So in Phx 1.3 final that would be
lib/my_app_web/plugs

alongside the controllers, channels, etc directories?

2 Likes

Yeah, I guess.

I usually call the “web interface” otp app just that, web, so for me it’s apps/web/lib/web/plugs actually. But that’s only relevant if you structure your app as an umbrella project.

2 Likes

+1 - thanks!