Skip to content

Actix Support? #11

Description

@tadghh

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions