Skip to content

Commit da63e9c

Browse files
Add detailed comments explaining controller and model functionality in slides
1 parent db6a3de commit da63e9c

1 file changed

Lines changed: 33 additions & 0 deletions

File tree

presentation/slides.md

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,25 @@ async fn route(
277277
```
278278
````
279279

280+
<!--
281+
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.
282+
283+
It takes a request and a database connection pool. It returns a response with a body of bytes or an error.
284+
If we don’t recognise the request, we return a bad request response.
285+
286+
➡️ ➡️ ➡️
287+
288+
The route function dispatches the request: it receives incoming HTTP requests and decides which service should handle them.
289+
290+
291+
Requests are matched based on method + URI path:
292+
OPTIONS → handled by preflight() (CORS).
293+
POST /scan → forwarded to the scan service.
294+
POST /searches → forwarded to the search service.
295+
Any other request → returns 404 Not Found.
296+
So, the controller separates request handling from business logic, forwarding requests to services without performing the business logic itself.
297+
-->
298+
280299
---
281300
transition: slide-down
282301
---
@@ -339,6 +358,20 @@ transition: fade-out
339358
</div>
340359
</div>
341360

361+
<!--
362+
These are the models to access the database.
363+
364+
They are Rust structs and they have implemented functions.
365+
366+
They match the CRUD pattern, create, read, update and delete. We do not have deletions.
367+
368+
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.
369+
370+
As you see we have unit tests for each function we have implemented.
371+
372+
This concludes the overall architecture and a little introduction to code.
373+
-->
374+
342375
---
343376
transition: slide-left
344377
---

0 commit comments

Comments
 (0)