Commit Graph

9 Commits

Author SHA1 Message Date
Evan Buss
0f0540549d feat: request deduplication / debouncing
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.
2024-08-18 18:37:42 +00:00
dependabot[bot]
5d45afd419 build(deps): bump github.com/knadh/koanf/providers/file from 1.0.0 to 1.1.0 (#11)
Bumps [github.com/knadh/koanf/providers/file](https://github.com/knadh/koanf) from 1.0.0 to 1.1.0.
- [Release notes](https://github.com/knadh/koanf/releases)
- [Commits](https://github.com/knadh/koanf/compare/v1.0.0...v1.1.0)

---
updated-dependencies:
- dependency-name: github.com/knadh/koanf/providers/file
  dependency-type: direct:production
  update-type: version-update:semver-minor
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2024-08-12 10:02:07 -04:00
Evan Buss
9da7ea1bbc feat: environment configuration
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.
2024-08-11 18:47:46 +00:00
Evan Buss
ccc6217014 feat: structured logging improvements
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
2024-08-10 20:03:34 +00:00
Evan Buss
3d4af0bd61 refactor: cleanup
naming and other things
2024-07-13 19:37:57 +00:00
Evan Buss
4f3948943a feat: cookie authentication
use encrypted cookies to authenticate
basic auth feeds. most eReader browsers
don't support basic auth
2024-07-13 01:55:48 +00:00
Evan Buss
b683d0c9b6 feat: set up configuration
A YAML file is used to set the available feeds.
The CLI args can set the port and the path to the YAML file.
2024-07-12 15:10:48 +00:00
Evan Buss
7c63b06e05 it mostly works 2024-07-04 23:52:14 -04:00
Evan Buss
9daf7bf8b9 init 2024-07-04 14:39:25 -04:00