Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Actix Support? #11

Open
tadghh opened this issue Apr 27, 2024 · 0 comments
Open

Actix Support? #11

tadghh opened this issue Apr 27, 2024 · 0 comments

Comments

@tadghh
Copy link

tadghh commented Apr 27, 2024

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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant