chore: initialize containerized Go learning workbook (2026 DevOps/SRE)
This commit is contained in:
commit
84be3e5d77
64 files changed
+1382
No files matched your search
@@ -0,0 +1,14 @@
|
||||
# 02 — Nowoczesny Serwer HTTP (`net/http` Go 1.22+, JSON, Middleware)
|
||||
|
||||
Od Go 1.22 standardowy `http.ServeMux` wspiera metody i parametry ścieżki (`GET /items/{id}`) — często nie potrzebujesz zewnętrznego frameworka!
|
||||
|
||||
## Zadania (`server.go`)
|
||||
Zbuduj `NewHandler() http.Handler`:
|
||||
1. `GET /health` -> `200 OK`, `Content-Type: application/json`, `{"status":"ok"}`.
|
||||
2. `POST /echo` -> przyjmuje `{"message":"..."}`; odrzuca pusty `message` kodem `400`, inaczej zwraca `{"echoed":"...","len":N}`.
|
||||
3. Middleware dodający nagłówek `X-Service: go-learning`.
|
||||
|
||||
## Uruchomienie testów
|
||||
```bash
|
||||
make test PKG=./exercises/03-ecosystems/02-http-api-stdlib
|
||||
```
|
||||
Reference in new issue
Block a user