Kobo eReaders have a buggy browser that makes 2 requests for
the same HTTP resource when you click a link.
This change ensures that requests within a certain time frame
from the same IP, for the same path / query params will only
be executed a single time.
We record the http request response and replay it for the second
request. If we get 2 simultaneous requests, we use the
sync/singleflight library to ensure only the first request is actually
processed. The second waits for the shared result of the first.
This probably adds latency since some requests are blocked while
we determine if we already have a cache entry, but for a simple
service like this I don't think it matters.
Environment variables can now be used to configure any
config property including the feeds list.
This makes it easier to use in environments without access
to config files like GCR. Some may prefer not to have a separate
config file as well.
Also added build metadata to the docker image and binaries.
This change adds a child logger with request information to the
http request context. Also improved the log format for clarity.
- Unescaped the query string
- Use JSON log format when not in dev mode.
- Added request ip to the request child logger.
- The child logger is passed to the converter so we can associate
any errors with a specific request / file.
- Add book file name as a logger attribute
- Add user agent header as a logger attribute
- Log the "X-Forwarded-For" header, falling back to RemoteAddr