~/talk

How I Write HTTP Web Services After 8 Years

Talkat GopherCon Europe 2019 · 2019-05-30..06-01· [go, web-platform]
name:Mat Ryer
github:matryer
slides:none on file

Concrete Go patterns for production HTTP services: no global state, server struct with dependencies, centralize routing in routes.go and return handler closures so each endpoint has its own request/response types and lazy setup via sync.Once. Prefer handlerFunc/Handler types, factor respond/decode helpers, wire middleware explicitly, and use net/http/httptest to run isolated handler unit tests or full-stack ServeHTTP tests. These choices trade a bit more boilerplate for maintainability and testability.

AI-written summary · about

  1. 0:00Intro
  2. 3:16How to use this talk
  3. 4:16I tend to select for...
  4. 6:40Let's jump in...
  5. 7:34Constructor for server?
  6. 9:17Handlers hang off the server
  7. 10:16Naming handler methods
  8. 10:48Return the handler
  9. 11:35Take arguments for handler
  10. 12:47HandlerFunc over Handler
  11. 14:14Middleware are just Go functions
  12. 15:01Wire Middleware up in routes.go
  13. 15:40Abstract responding
  14. 16:37Abstract decoding
  15. 17:32Request and response data types
  16. 19:06Test types help frame the test
  17. 21:44Make server an http.Handler
  18. 22:33server is testable
  19. 23:35Middleware are testable too
~/search
type to search 6,249 conferences, 138,987 speakers and 185,172 talks
~/help
cmdctrl k
search every conference, speaker and series
/
focus the filter search
h
home
c
conferences
s
speakers
e
series
t
light / dark — the status bar button does the same
?
this help
esc
close this, then clear every filter — or just the search, while you are typing in it

Ignored while you are typing. Pages without a filter rail have no search to focus.