-
Notifications
You must be signed in to change notification settings - Fork 4
3. Initializations and Configurations
kooinam edited this page Sep 3, 2020
·
4 revisions
To ensure proper initializations of Fab.io, do the following:
func main() {
fab.ConfigureAndServe(&FabInitializer{})
}FabInitializer needs to implement the following functions:
-
Configure(*Configuration)can be used to configure configurations like port and http handler.
// Configure used to configure configurations
func (initializer *FabInitializer) Configure(configuration *fab.Configuration) {
configuration.SetPort("8000")
configuration.SetHttpHandler(func() {
fs := http.FileServer(http.Dir("./demo"))
http.Handle("/demo/", http.StripPrefix("/demo/", fs))
})
}-
RegisterAdapters(*models.Manager)can be used to register adapters. -
RegisterCollections(*models.Manager)can be used to register collections. -
RegisterControllers(*controllers.Manager)can be used to register controllers. -
RegisterViews(*views.Manager)can be used to register views. -
BeforeServe()can be used to implementing customized application initialization logics like loading application data.BeforeServewill be called after Fab.io initializes and before starting to serve.