-
Hi,
But I get this error:
So how would I do something like this? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments
-
Currently, AFIT is not stable, check here. So we cant do that. Use async-trait crate to helping us. #[derive(Clone)]
struct Handler {
/**
* Request handlers for incoming requests to this server
*/
handlers: Arc<tokio::sync::RwLock<HashMap<String, HandlerFunction>>>,
}
#[async_trait::async_trait]
impl viz::Handler<Request> for Handler {
type Output = viz::Result<Response>;
async fn call(&self, req: Request) -> Self::Output {
let path = req.path().clone();
let method = req.method().clone();
let count = self.count.fetch_add(1, Ordering::SeqCst);
Ok(format!("method = {method}, path = {path}, count = {count}").into_response())
}
} Sorry, I forgot to add it in the documentation, I'll fix it. Thanks. |
Beta Was this translation helpful? Give feedback.
-
Fixed. The docs have updated. |
Beta Was this translation helpful? Give feedback.
Currently, AFIT is not stable, check here. So we cant do that.
Use async-trait crate to helping us.
Sorry, I forgot to ad…