A Umbrella project with several applications containing UI logic.

I have 2 applications that have common functionality / routes. For example, in both applications there is a diary, goal tracking, sleep tracking, etc., which work the same way. There are also routes specific to each application. In AppA, the user can track their mood, and in AppB, the user can view notes from their doctor.

Is there a way to create an umbrella project containing in a /appscommon application, AppA and AppB? Each application will have its own router / controllers / templates, etc. AppA and AppB will require GenericApp as a dependency. So far, I have only seen umbrella projects with one application that contains the interface logic (web interface), and other applications are libraries that are included. How can this work with routing in multiple applications? Is there any other approach I can take for this?

I found this question and answer in my search, however this is not quite what I am looking for. It seems to fit the pattern of one external application, including in other libraries.

+6
source share
1 answer

Yes, you can divide the β€œgeneral” routes into a separate umbrella application and forwardfrom AppAand to it AppB.

Use Phoenix.Router.forward / 4 to forward requests from AppAand AppBto common code.

For example, here's how exq_ui can be included in 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
+4
source

All Articles