leptos-image icon indicating copy to clipboard operation
leptos-image copied to clipboard

Actix Support?

Open tadghh opened this issue 9 months ago • 0 comments

Is there some way to make this work with Actix? I have the following but the server cannot see the image optimizer, Im assuming this is because leptos_router..._context doesnt not accept primatives.

HttpServer::new(move || {
        let leptos_options = &conf.leptos_options;
        let site_root = &leptos_options.site_root;
        let optimizer = ImageOptimizer::new("/__cache/image", site_root.clone(), 1);

        let state = AppState {
            leptos_options: leptos_options.clone(),
            optimizer: optimizer.clone(),
        };
        App::new()
            .service(css)
            .route("/api/*fn_name", leptos_actix::handle_server_fns())
            // serve JS/WASM/CSS from `pkg`
            .service(Files::new("/pkg", format!("{site_root}/pkg")))
            // serve other assets from the `assets` directory
            .service(Files::new("/public", site_root))
            // serve the favicon from /favicon.ico
            .service(favicon)
            .leptos_routes(leptos_options.to_owned(), routes.to_owned(), App)
            .leptos_routes_with_context(
                leptos_options.clone(),
                generate_route_list(App),
                optimizer.provide_context(),
                App,
            )
            .app_data(web::Data::new(state.to_owned()))
        //.wrap(middleware::Compress::default())
    })
    .bind(&addr)?
    .run()
    .await

tadghh avatar Apr 27 '24 04:04 tadghh