Admin configuration
Enable and configure the admin panel.
● ● ●
RuniqueApp::builder(config)
.with_admin(|a| {
a.site_title("My Administration")
.auth(RuniqueAdminAuth::new())
.routes(admins::routes("/admin"))
// Custom dashboard (optional)
.templates(|t| t.with_dashboard("admin/my_dashboard.html"))
.with_state(admins::admin_state())
})
// The AdminAuth interface specifies how
// a user attempting to log into the admin is validated.
// By default, Runique provides DefaultAdminAuth:
pub struct MyAdminAuth;
#[async_trait]
impl AdminAuth for MyAdminAuth {
async fn authenticate(&self, username: &str, password: &str, db: &DatabaseConnection) -> Option<AdminLoginResult> {
// Custom verification code...
None
}
}
// In the builder:
.auth(MyAdminAuth)
// For each resource declared in admin!:
GET /admin/ → dashboard
GET /admin/article/ → list
GET /admin/article/create/ → create form
POST /admin/article/create/ → create handler
GET /admin/article/{id}/edit/ → edit form
POST /admin/article/{id}/edit/ → edit handler
POST /admin/article/{id}/delete/ → delete