~/talk

Write Once, Use Many: A Handy Package to Call Internal HTTP APIs

Talkat GopherCon 2020 · 2020-11-09..11-13· [api-design, go]
slides:none on file

A reusable Go package called bitly service encapsulates all internal HTTP calls so one implementation handles service discovery, host selection via a hostpool, consistent headers and JSON unmarshalling, logging, tracing, timeouts, and error handling. Initialization requires calling must_add_named_api which panics on misconfiguration, and testing uses a hook mechanism to mock responses. The code reduces repeated client.Request/Client.Do boilerplate to thin wrappers (get/post/put/patch/delete) and is used 336 times across the codebase.

AI-written summary · about

  1. 0:00Intro
  2. 1:17Bitly System Architecture
  3. 2:38Standard lib HTTP calls
  4. 6:33Solution - Encapsulate it all into a reusable package
  5. 8:02Under the covers - bitlyservice does all the work
  6. 8:58bitlyservice. NewRequest() - What does it do?
  7. 13:03First piece: Service Discovery
  8. 14:03Application Startup
  9. 15:37Service Validation - MustAddNamedAPI()
  10. 18:35Unit testing with hooks
  11. 19:41The HTTP call and all things surrounding it
  12. 29:22Climbing back out...
~/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.