|
Hi, But I get this error: So how would I do something like this? |
Answered by
fundon
Dec 12, 2022
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. |
0 replies
Answer selected by
m1212e
|
Fixed. The docs have updated. |
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Currently, AFIT is not stable, check here. So we cant do that.
Use async-trait crate to helping us.
Sorry, I forgot to ad…