feat: reorganize workbook into 3 tracks (core, engineering-2026, ecosystems)
This commit is contained in:
1 parent
82677455b2
commit
2e002b6176
64 files changed
+2295
-196
No files matched your search
@@ -0,0 +1,18 @@
|
||||
# 02 — Web Backend z `axum` + `tokio` + `serde`
|
||||
|
||||
`axum` (oparty na `tokio` i `tower`) to najpopularniejszy nowoczesny framework backendowy w Ruście.
|
||||
|
||||
## Zakres
|
||||
* Routing HTTP (`Router::new().route(...)`)
|
||||
* Serializacja/deserializacja JSON (`axum::Json`, `serde::Serialize`, `serde::Deserialize`)
|
||||
* Kody statusu HTTP (`StatusCode`) i testowanie routera w pamięci bez otwierania portów (`tower::ServiceExt::oneshot`)
|
||||
|
||||
## Zadania (`src/lib.rs`)
|
||||
Zbuduj router w `build_router()`:
|
||||
1. `GET /health` -> zwraca `200 OK` i JSON `{"status": "ok"}`.
|
||||
2. `POST /echo` -> przyjmuje JSON `EchoRequest { message: String }`; jeśli `message.trim().is_empty()`, zwraca `400 BAD_REQUEST`, inaczej `200 OK` z `EchoResponse { echoed: message, len }`.
|
||||
|
||||
## Uruchomienie testów
|
||||
```bash
|
||||
make test PKG=eco02-web-backend-axum
|
||||
```
|
||||
Reference in new issue
Block a user