You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Or use the provided `docker-compose.yml` configuration:
33
42
34
-
```bash
43
+
```yaml
35
44
docker-compose up -d
36
45
# edit docker-compose.yml to set APP_TOKEN or update the environment
37
46
```
38
47
39
-
The server listens on `API_PORT` (default `8080`) and stores the BoltDB file at `DB_PATH` (default `short-it.db`).
48
+
The primary API and redirect server listens on `API_PORT` (default `8080`). If enabled, the Web UI listens on `WEB_UI_PORT` (default `8090`).
49
+
The BoltDB file is stored at `./short-it.db` by default, or `/data/short-it.db` in Docker configurations.
40
50
41
51
Or deploy it in one click:
42
52
43
53
[](https://railway.com/deploy/UaONmD?referralCode=Zw7fpP&utm_medium=integration&utm_source=template&utm_campaign=generic)
44
54
55
+
> **Note:** Ensure you update the environment variables to match the latest version when deploying.
56
+
45
57
## Configuration
46
58
47
59
Environment variables:
48
60
49
-
-`APP_TOKEN` (required): token used for authorization on protected endpoints
50
-
-`API_PORT` (optional): HTTP port (default `8080`)
51
-
-`API_URL` (optional): URL to access the API (default `http://localhost:8080`)
52
-
-`DB_PATH` (optional): path to BoltDB file (default `short-it.db`)
53
-
-`WEB_UI` (optional): set to `true` to host a small link-creation webpage
54
-
-`WEB_UI_URL` (optional): URL to access the web UI (default `http://localhost:8090`)
55
-
-`WEB_UI_PORT` (optional): port for the web UI server (default `8080`)
56
-
-`RYBBIT_SITE_ID` (optional): Site ID provided by Rybbit
57
-
-`RYBBIT_SITE_KEY` (optional): API key found in account settings for Rybbit
58
-
-`RYBBIT_SITE_URL` (optional): Base URL for your Rybbit instance
61
+
### Core Setup
59
62
60
-
Notes for `WEB_UI`:
63
+
*`APP_TOKEN` (required): Token used for authorization on protected API endpoints.
61
64
62
-
- The API server still listens on `API_PORT`.
63
-
- The web UI starts only when `WEB_UI=true`.
64
-
- If `WEB_UI_PORT` is the same value as `API_PORT`, the UI is skipped to avoid interfering with the API process.
65
+
*`API_PORT` (optional): Port for the main API and URL redirection (default `8080`).
65
66
66
-
## HTTP API
67
+
*`API_URL` (optional): Explicit base URL used for generating shortened links in the Web UI. Intelligently inferred if omitted.
67
68
68
-
All endpoints that modify or list data require the `Authorization` header to equal the `APP_TOKEN` value.
69
+
*`DB_PATH` (optional): Filepath for the BoltDB database (default `short-it.db`).
* Redirects (302 Found) to the stored URL if it exists.
116
+
117
+
## Web UI
118
+
119
+
If `WEB_UI=true` is set, a web interface is exposed on `http://localhost:8090` (or `WEB_UI_PORT`).
120
+
121
+
*`GET /`: Serves the HTML interface to easily create short URLs.
120
122
121
-
Key implementation files:
123
+
*`POST /api/create`: Internal endpoint used by the Web UI form.
122
124
123
-
-[cmd/short-it/main.go](cmd/short-it/main.go#L1) — HTTP handlers and core logic
124
-
-[cmd/short-it/main_test.go](cmd/short-it/main_test.go#L1) — unit tests for handlers and DB ops
125
-
-[Dockerfile](Dockerfile) — container build
126
-
-[docker-compose.yml](docker-compose.yml) — example compose configuration
125
+
### Notes
127
126
128
-
## Notes
127
+
* The app uses a BoltDB bucket named `urls` to store key → URL mappings.
129
128
130
-
- The app uses a BoltDB bucket named `urls` to store key → URL mappings.
131
-
- The autogenerated keys are 6 characters drawn from `a-zA-Z0-9`.
132
-
- Sends pageview events to Rybbit if configured with the hostname, language, pathname, user-agent, referrer, and IP address gathered from `X-Forwarded-For`.
129
+
* The autogenerated keys are 6 characters drawn from `a-zA-Z0-9`.
0 commit comments