![actix-web middleware actix-web middleware](https://files.speakerdeck.com/presentations/ecde5b176f0a47f391293ba813f7c2da/slide_57.jpg)
We grab the bounding boxes, put them in our handy dandy BBox struct: //Our bounding box extents This has not changed at all since our main method. We'll start by creating a new file mtcnn.rs and adding in the struct definition.
![actix-web middleware actix-web middleware](https://user-images.githubusercontent.com/36012050/108704774-c3cd4880-750c-11eb-9b4d-ca3d79fd2eed.png)
In our last blog we just simply used the main function to perform everything, but it's not going to fly with actix until we do a bit of a refactor. Either return Bounding Boxes as JSON, or an Image Overlay as a JPEG like the command line example.Run a session against mtcnn to extract faces.Submit POST request as a raw file submission.I think the easiest would be just the raw data so let's do that! Multipart could possibly also work, but what about the case when you have to handle multiple images? JSON Submission seems a bit wasteful, as you would inevitably have to convert binary data using base64 or similar.
![actix-web middleware actix-web middleware](https://user-images.githubusercontent.com/57934/116048425-280ea480-a643-11eb-90ca-3c9a794bfec3.png)
#Actix web middleware code#
Once again for the impatient, you can find the reference code here on the actix-web branch: I think you should get your hands dirty now: async programming will always be challenging and the changes being introduced only affect ergonomics, not fundamentals) (Some people have suggested waiting for async/await and friends to land before diving into Futures. For this, I suggest you start with tokio. I will do my best to explain in simpler terms, but understanding the futures ecosystem would be quite handy to help work through this article. This article assumes you have some knowledge about Futures and how they work. As Actix Web is nearing its inevitable 1.0 release, I thought it would be a great time to build something with it. This time we're going to take what we've built on, and serve it as an HTTP API call.
#Actix web middleware how to#
Last article I wrote about how to use tensorflow with rust. Face Detection with Actix Web Using MTCNN with Actix Web