This is a straight refactor with no functional changes. All file access
is captured in the FileDB type. The DB interface is not strictly
necessary here since we only have a single implementation, but helped to
keep the API clean, which will be useful in a future sqlite migration.
Change-Id: I9b86db3040e2618a4ffef237369288ccfc10bc1e
This sets up an embed.FS even though we only have the one file right
now, as we will have more shortly.
Change-Id: I1292e4c00602fbfc3a7bc2a5f93a8c9b9e6715c0
Otherwise we can't save a link using the funcs.
Change-Id: If48e1527f5b21f0314d3e1b4c3c38b9ca7fa65b8
Signed-off-by: Brad Fitzpatrick <bradfitz@tailscale.com>
long URLs are now executed using text/template to allow for more advaned
handling. Templates have access to PathEscape and QueryEscape funcs, as
well as a data struct containing the current time (Now) and the
remaining path from the user-provided short link (Path).
Change-Id: Iedbbafccf98c4a623d06e9519877c7137ca559e8
- ignore hyphens, preventing link ambiguity. If hyphens are included
when creating the link, they are saved as the "canonical" name for
the link, but links are still resolved without them.
- allow overwriting the "canonical" name for a short link by simply
recreating it with the new canonical name. Stats are not updated when
the canonical name is updated, which is probably fine.
Change-Id: Ia962caa846489850784ef15cdfad7f13bafd8842
In the meantime, before sqlite-and-litestream-to-S3, and as a
transition mechanism to move this service to be running on Fly instead
of Brad's dev box, add support for backing up the go/ links to a file
in git, baking it into the binary, and restoring it as needed when the
binary starts up, including in a newly added dev mode.
Change-Id: I8961f720c0f9b29eb7b0b6b1f62bac7ace2d67dc