trillium-rs / trillium

Trillium is a composable toolkit for building internet applications with async rust

Home Page:https://trillium.rs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Cannot run nesting router example

edyu opened this issue · comments

commented

Was just testing out the code on the Nesting example Nesting Router and have the following error:

`
Listening at 127.0.0.1:8080 (bound as tcp://127.0.0.1:8080)

Control-C to quit
thread 'main' panicked at 'cannot call init when there are already clones of an Arc', /home/ed/.cargo/registry/src/github.com-1ecc6299db9ec823/trillium-0.2.2/src/handler.rs:211:14
note: run with RUST_BACKTRACE=1 environment variable to display a backtrace
`

Thank you for filing! This makes sense and was introduced in trillium-router v0.3.1. I will release a fix as trillium-router v0.3.2 within a day, likely much less.

In the mean time, replace the use of .any with .all:

// ...
        Router::new()
            .get("/", |conn: Conn| async move { conn.ok("hello everyone") })
            .all("/users/:user_id/*", nested_app::handler()),
// ...

Released trillium-router@v0.3.2, please let me know if you encounter any other issues! Thanks again for reporting this