Compilable code for Mat Ryer's GopherCon 2019 talk, How I Write HTTP Web Services after Eight Years.
I took these notes while watching the talk. I obviously did not create this code, and Mat Ryer has not, as far as I know, licensed it. For this reason, I will be more than happy to take this repo private.
The fact that this code compiles is not that important since it does nothing interesting. But the
ANCILLARY STUB
sections do show what types might satisfy some of Mat's slide code, and in addition
it makes the occasionally inconsistent slide code consistent.
Timecode | Topic | File |
---|---|---|
8:18 | code discussion starts | |
9:25 | main and run | main.go |
10:08 | server type | server.go |
11:24 | server constructor | server.go |
12:57 | server as http.Handler | server.go |
14:11 | routes file | routes.go |
15:18 | handlers as server methods | handlermethods.go |
17:03 | handler-specific setup | handlermethods.go |
18:08 | handler method arguments | handlermethods.go |
19:39 | multiple server types | server.go |
20:24 | HandlerFunc vs. Handler | |
21:54 | middleware | middleware.go |
24:39 | some common (premature?) abstractions | encodedecode.go |
27:57 | inner types | handlermethods.go |
29:21 | lazy setup with sync.Once | handlermethods.go |
31:56 | testing with httptest and is | |
33:43 | testing servers | server_test.go |
37:18 | testing inner types | server_test.go |
38:46 | integration vs. unit tests | server_test.go |
40:13 | e2e tests | server_test.go |
41:15 | testing middleware | server_test.go |
While the code compiles, the tests panic. The stubs compile but in many cases are not valid due to nil pointer dereferencing. This is intentional, since it makes the stubs as minimal as possible. My goal was to make them as close to, e.g., function signatures, as the compiler would let me.