I have 2 applications which have shared functionality/routes. For example, in both applications there is a diary, goal tracking, sleep tracking, etc which work in the same way. There are also routes specific to each app. In AppA, a user can track their mood, and in AppB a user can view notes from their doctor.
Is there a way to have an umbrella project which contains in /apps
the generic app, AppA, and AppB? Each app will have it's own router/controllers/templates etc. AppA and AppB will each require the GenericApp as a dependency. So far I have only seen umbrella projects with one app that contains the front end logic (web), with the other apps being libraries that are included in. How can this work with routing across multiple apps? Is there another approach I can take for this?
I have found this question & answer in my search, however it is not exactly what I am looking for. It seems to follow the pattern of one front end app including in other libraries.
Yes, you can certainly split out the 'generic' routes into a separate umbrella app and forward
to it from AppA
and AppB
.
Use the Phoenix.Router.forward/4 function to forward requests from AppA
and AppB
to the shared code.
For example, this is how the exq_ui can be incorporated into a larger application:
pipeline :exq do
plug :accepts, ["html"]
plug :fetch_session
plug :fetch_flash
plug :put_secure_browser_headers
plug ExqUi.RouterPlug, namespace: "exq"
end
scope "/exq", ExqUi do
pipe_through :exq
forward "/", RouterPlug.Router, :index
end
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With