-
I want to place the route separately, I quickly checked the example, it will fail to compile. pub fn app(db: DbConn) -> Route {
route()
.at("/hello/:name", get(hello))
.with(RateLimitLayer::new(5, Duration::from_secs(30)).compat())
.with(TimeoutLayer::new(Duration::from_secs(30)).compat())
.with(AddData::new(db))
} |
Beta Was this translation helpful? Give feedback.
Answered by
sunli829
Sep 30, 2021
Replies: 1 comment 1 reply
-
Should return pub fn app(db: DbConn) -> impl Endpoint {
route()
.at("/hello/:name", get(hello))
.with(RateLimitLayer::new(5, Duration::from_secs(30)).compat())
.with(TimeoutLayer::new(Duration::from_secs(30)).compat())
.data(db) // similar to .with(AddData::new(db))
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Oodachi
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Should return
impl Endpoint
, becausewith
wraps the originalRoute
type into another type.