laravel-rust-admin 0.1.0

Admin panel framework for Laravel for Rust: auto-generated CRUD tables, forms, actions, and dashboard widgets from your models.
Documentation
//! Admin panel route registration under the configured prefix.

use laravel::http::MiddlewareGroup;
use laravel::routing::Router;

use crate::http::handlers;

pub(crate) fn register_routes(route: &mut Router, prefix: &str, middleware: MiddlewareGroup) {
    route.prefix(prefix).middleware(middleware).group(|route| {
        // The JSON API that the embedded SPA talks to. A record's key always sits under
        // `/records/`, so a key such as `export` can never be mistaken for another endpoint.
        route.get("/api/panel", handlers::panel_schema);
        route.get("/api/dashboard", handlers::dashboard);
        route.get("/api/search", handlers::global_search);

        route.get("/api/resources/{slug}", handlers::list_records);
        route.post("/api/resources/{slug}", handlers::create_record);
        route.get("/api/resources/{slug}/export", handlers::export_records);
        route.post("/api/resources/{slug}/bulk/{action}", handlers::run_bulk_action);

        route.get("/api/resources/{slug}/records/{id}", handlers::show_record);
        route.patch("/api/resources/{slug}/records/{id}", handlers::update_record);
        route.put("/api/resources/{slug}/records/{id}", handlers::update_record);
        route.delete("/api/resources/{slug}/records/{id}", handlers::delete_record);
        route.post(
            "/api/resources/{slug}/records/{id}/actions/{action}",
            handlers::run_row_action,
        );

        // The SPA shell. Every other path under the prefix is a client-side route.
        route.get("/", handlers::shell_root);
        route.get("/{*path}", handlers::shell_fallback);
    });
}