Website using actix-web

I created a basic webiste using actix-web (Github repo) Is the code good?

1 Like

At a first glance it looks good to me. Is there something in particular that you'd like to improve in it?

The nesting in some functions looks deep.Is it ok?

The nesting is fine. One thing I notice is your get_connection function, which you sometimes call directly in async code (e.g. here). However, as far as I understand, the Pool::get function is blocking.

So should I use something like web::block in the get_connection function

Yes. Alternatively you can use a database library designed for async/await.

So I should do something like this right?

Yes, that's fine.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.