General Configuration
You could customize Admin with AdminConfig
struct when initializing it, here are some general configurations:
type AdminConfig struct {
SiteName string
DB *gorm.DB
Auth Auth
SessionManager session.ManagerInterface
I18n I18n
AssetFS assetfs.Interface
*Transformer
}
-
By Default, Site Name is
Qor Admin
, you can useSiteName
to change site's title.Admin := admin.New(&admin.AdminConfig{SiteName: "Qor Example"})
hint: You can inject stylesheets, javascripts into your admin site with your site's title
DB
DB
is a GORM DB connection, it is required, QOR Admin will use the DB to manage data.Auth
Auth is used for Authentication
SessionManager
Admin use SessionManager to handle cookies, flash messages, learn to customize it
I18n
Internationalization solution for Admin
-
AssetFS defined how to look up templates when rendering pages, refer View Paths for more detail, when deploy your site to production, you usually want your application to be standalone executable, check out Deploy to production for how to.
Transformer
Dashboard
QOR Admin provides a default dashboard page with some dummy text. If you want to customize the dashboard, you can create a file dashboard.tmpl
in QOR view paths, QOR Admin will load it as Golang templates when rendering the dashboard page.
If you want to disable the dashboard, you can redirect it to some other page, for example:
Admin.GetRouter().Get("/", func(c *admin.Context) {
http.Redirect(c.Writer, c.Request, "/admin/clients", http.StatusSeeOther)
})