Flamingo Bootstrap

The Flamingo Bootstrap takes care of:

  • Define the configuration Areas
  • Load default configuration
  • Load the current configuration and routing information
  • Load overriding configuration
  • Configures dingo dependency injection
  • Register additional Handlers
  • Run the main command (root command) that will start the specified command.
    • In case it is the "serve" command that will for example start the server and a router

Configuration context areas

You can have several configuration areas in your project.

Configuration areas have:

  • a name
  • a list of modules to load
  • child config areas

With the concept of having children, the config areas in your project can form a tree. Inside the tree, most of the configurations and modules are inherited to the children.

This concept is mainly used to configure different websites/channels with different locales or different implementations of certain ports for example.
Therefore this is often used together with the prefixrouter Module and uses the configured url prefix to allow the Router to "detect" and use the correct configuration area.

Using the default flamingo.App

A typical Flamingo application with multiple config areas will look like this:

Folder structure:

main.go
config
└───config.yml
│   └───config.yml
└───de
│   └───config.yml
└───en
    └───config.yml  

Inside main.go you can use the flamingo.App as an entrypoint to run your application:

func main() {

    flamingo.App([]dingo.Module{
        //flamingo framework modules:
        new(requestlogger.Module), // requestlogger show request logs
        new(prefixrouter.Module),
        new(pugtemplate.Module),
        new(locale.Module),
        new(opencensus.Module),
        new(auth.Module),

        //flamingo-commerce modules
        new(product.Module),
        new(price.Module),
        new(category.Module),
        new(cart.Module),
        new(customer.Module),
        new(checkout.Module),

        //flamingo-commerce-adpater-standalone
        new(csvcommerce.ProductClientModule),
        new(csvcommerce.SearchClientModule),
    }, flamingo.ChildAreas(
        config.NewArea("de", nil),
        config.NewArea("en", nil),
    ))
}