You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Our controller is simple - a single function responsible for handling the incoming HTTP requests and dispatching the request to the handler using the route function.
337
-
338
-
It takes a request and a database connection pool. It returns a response with a body of bytes or an error.
339
-
If we don’t recognise the request, we return a bad request response.
340
-
341
-
➡️ ➡️ ➡️
342
-
343
-
The route function dispatches the request: it receives incoming HTTP requests and decides which service should handle them.
344
-
345
-
346
-
Requests are matched based on method + URI path:
347
-
OPTIONS → handled by preflight() (CORS).
348
-
POST /scan → forwarded to the scan service.
349
-
POST /searches → forwarded to the search service.
350
-
Any other request → returns 404 Not Found.
351
-
So, the controller separates request handling from business logic, forwarding requests to services without performing the business logic itself.
They are Rust structs and they have implemented functions.
420
-
421
-
They match the CRUD pattern, create, read, update and delete. We do not have deletions.
422
-
423
-
Taking create as an example: It takes barcode String, unsigned 32 bit location id, and connection pool. It returns a Result of either Labware or a LabwareError. This is a common pattern in Rust. Using Result allows the caller to handle success and failure explicitly.
424
-
425
-
As you see we have unit tests for each function we have implemented.
426
-
427
-
This concludes the overall architecture and a little introduction to code.
So now, I’ll walk you through some of the code running behind the demonstration that Shiv just showed. The goal here is simply to give you a sense of how things are structured under the hood. The full codebase is available on GitHub for you to explore at your own pace. We will share the GitHub links for you to go through after the presentation.
@@ -569,10 +504,10 @@ You've heard about Rust, and now you have seen it too!
569
504
570
505
<br>
571
506
572
-
- <v-markv-mark.highlight.yellow="2"> <b>Collaborative learning</b> </v-mark> played a key role in helping us reach this milestone.
573
-
- <v-markv-mark.highlight.yellow="3"> <b>Consistent, small weekly efforts</b> </v-mark> added up and brought us to this point.
574
-
- <v-markv-mark.highlight.yellow="4"> <b>Keeping abstractions to a minimum</b> </v-mark> helped us better appreciate Rust’s core philosophy.
575
-
- <v-markv-mark.highlight.yellow="5"> <b>Learning together kept our motivation high</b></v-mark>, and we’ve since kept the momentum going through open-source projects.
507
+
- <v-markv-mark.highlight.yellow="2"> <b>Consistent, small weekly efforts</b> </v-mark> added up and brought us to this point.
508
+
- <v-markv-mark.highlight.yellow="3"> <b>Minimal use of out-of-the-box frameworks</b> </v-mark> helped us better appreciate Rust’s core philosophy.
509
+
- <v-markv-mark.highlight.yellow="4"> <b>Learning together kept our motivation high</b> </v-mark>, and we’ve since kept the momentum going through open-source projects.
510
+
-Because our <v-markv-mark.highlight.yellow="5"> <b>collaborative learning</b></v-mark> sessions were highly effective, we plan to carry that approach forward into our PSD work.
0 commit comments