mirror of
https://github.com/Xevion/time-banner.git
synced 2025-12-05 23:16:35 -06:00
doc: request path documentation
This commit is contained in:
54
README.md
54
README.md
@@ -29,13 +29,57 @@ My first Rust project, intended to offer a simple way to display the current tim
|
|||||||
|
|
||||||
## Routes
|
## Routes
|
||||||
|
|
||||||
```shell
|
`GET /[relative|absolute]/[value]{.ext}?tz={timezone}&format={format_string}&now={timestamp}&static={boolean}`
|
||||||
/{time}[.{ext}]
|
|
||||||
/{rel|relative}/{time}[.{ext}]
|
- `{relative|absolute}` - The display format of the time.
|
||||||
/{abs|absolute}/{time}[.{ext}]
|
- `{value}` - The time value to work with. Relative values can be specified by prefixing with `+` or `-`.
|
||||||
|
- Relative values are relative to the value acquired from the `now` parameter (which defaults to the current time).
|
||||||
|
- Whether the value is relative or absolute has nothing to do with the display format.
|
||||||
|
- `/absolute/+0` will display the current time in UTC.
|
||||||
|
- Note: The `now` parameter is returned in the `Date` response header.
|
||||||
|
- `Accept` or `{.ext}` - Determines the output format. If not specified, `.svg` is assumed.
|
||||||
|
- `Accept` requires a valid MIME type.
|
||||||
|
- `.ext` requires a valid extension.
|
||||||
|
- Supported values: `.png`/`image/png`,
|
||||||
|
- `X-Timezone` or `?tz={timezone}` - The timezone to display the time in. If not specified, UTC is assumed.
|
||||||
|
- `?format={format}` - The format of the time to display. If not specified, `%Y-%m-%d %H:%M:%S` is assumed.
|
||||||
|
- Only relevant for `absolute` values.
|
||||||
|
- `X-Date-Now` or `?now={timestamp}` - The timestamp to use for relative time calculations. If not specified, the current time is used.
|
||||||
|
- `?static={boolean}` - Whether to redirect to a static version of the URL. Useful for creating specific URLs manually.
|
||||||
|
- If a value is not passed, (`?static`), `true` is assumed. Anything other than `true`, `1` or `yes` (case-insensitive) is considered `false`.
|
||||||
|
- Some header values will be translated to query parameters if provided (not `Accept`).
|
||||||
|
- e.g. `/rel/+3600.png?static&now=1752170474` will redirect to `/relative/1752174074.png`
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
```
|
||||||
|
/1752170474 => 2025-07-10 12:01:14 UTC
|
||||||
|
/abs/1752170474 => 2025-07-10 12:01:14 UTC
|
||||||
|
/absolute/+3600 => 2025-07-10 13:01:14 UTC
|
||||||
|
/abs/-1800 => 2025-07-10 11:01:14 UTC
|
||||||
|
/rel/1752170474 => 15 minutes ago
|
||||||
|
/rel/+3600 => 1 hour from now
|
||||||
|
/relative/-1800 => 30 minutes ago
|
||||||
|
/relative/1752170474.png?tz=America/Chicago => 2025-07-10 06:01:14 CDT
|
||||||
|
/relative/1752170474?type=relative => 2081-01-17 12:02:28 PM
|
||||||
```
|
```
|
||||||
|
|
||||||
- If relative or absolute is not specified, it will be the opposite of the time string's format.
|
## Ideas
|
||||||
|
|
||||||
|
- Support for different timezone formats in query parameters or headers
|
||||||
|
- `?tz=...` or `X-Timezone: ...`
|
||||||
|
- `CST` or `America/Chicago` or `UTC-6` or `GMT-6` or `-0600`
|
||||||
|
- Automatically guessed based on geolocation of source IP address
|
||||||
|
- Complex caching abilities
|
||||||
|
- Multi-level caching (disk, memory)
|
||||||
|
- Automatic expiry of relative items
|
||||||
|
- `Accept` header support
|
||||||
|
- IP-based rate limiting
|
||||||
|
- Multi-domain rate limiting factors
|
||||||
|
- Computational cost: 1ms = 1 token, max 100 tokens per minute
|
||||||
|
- Base rate: 3 requests per second
|
||||||
|
- Cached Conversions
|
||||||
|
- If PNG is cached, then JPEG/WEBP/etc. can be converted from cached PNG
|
||||||
|
|
||||||
### Query Parameters
|
### Query Parameters
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user