|
7 | 7 | - Docker (recommended) |
8 | 8 | - A built SPA bundle (for example, `dist/` from Vite, Webpack, or similar) |
9 | 9 |
|
10 | | -## Serve a Local Build |
| 10 | +## Local Run (Console) |
| 11 | + |
| 12 | +Build from source and run the server directly: |
| 13 | + |
| 14 | +```bash |
| 15 | +cd src |
| 16 | +go build -o spa-to-http |
| 17 | +./spa-to-http --directory ../test/frontend/dist |
| 18 | +``` |
| 19 | + |
| 20 | +Or run without building a binary: |
| 21 | + |
| 22 | +```bash |
| 23 | +cd src |
| 24 | +go run . --directory ../test/frontend/dist |
| 25 | +``` |
| 26 | + |
| 27 | +Open `http://localhost:8080` in your browser. |
| 28 | + |
| 29 | +### Configure via CLI Flags |
| 30 | + |
| 31 | +```bash |
| 32 | +cd src |
| 33 | +go run . \ |
| 34 | + --directory ../test/frontend/dist \ |
| 35 | + --brotli \ |
| 36 | + --gzip \ |
| 37 | + --spa=true \ |
| 38 | + --logger \ |
| 39 | + --log-pretty \ |
| 40 | + --cache-max-age 3600 \ |
| 41 | + --threshold 2048 |
| 42 | +``` |
| 43 | + |
| 44 | +### Configure via Environment Variables |
| 45 | + |
| 46 | +```bash |
| 47 | +cd src |
| 48 | +ADDRESS=0.0.0.0 PORT=8080 \ |
| 49 | +GZIP=true BROTLI=true \ |
| 50 | +SPA_MODE=true LOGGER=true LOG_PRETTY=true \ |
| 51 | +CACHE_MAX_AGE=3600 THRESHOLD=2048 \ |
| 52 | +DIRECTORY=../test/frontend/dist \ |
| 53 | +go run . |
| 54 | +``` |
| 55 | + |
| 56 | +Full list of options is in [Configuration](configuration.md). |
| 57 | + |
| 58 | +## Serve a Local Build (Docker) |
11 | 59 |
|
12 | 60 | ```bash |
13 | 61 | # Serve ./dist at http://localhost:8080 |
@@ -39,6 +87,25 @@ Build and run: |
39 | 87 | docker build -q . | xargs docker run --rm -p 8080:8080 |
40 | 88 | ``` |
41 | 89 |
|
| 90 | +## Test With `test/frontend/dist` |
| 91 | + |
| 92 | +Use the built-in fixture to verify routing, caching, and compression behavior. |
| 93 | + |
| 94 | +### Console |
| 95 | + |
| 96 | +```bash |
| 97 | +cd src |
| 98 | +go run . --directory ../test/frontend/dist |
| 99 | +``` |
| 100 | + |
| 101 | +### Docker |
| 102 | + |
| 103 | +```bash |
| 104 | +docker run --rm -p 8080:8080 -v $(pwd)/test/frontend/dist:/code devforth/spa-to-http:latest |
| 105 | +``` |
| 106 | + |
| 107 | +Open `http://localhost:8080` in your browser. |
| 108 | + |
42 | 109 | ## Next Steps |
43 | 110 |
|
44 | 111 | - Configure compression, cache settings, and ports in [Configuration](configuration.md) |
|
0 commit comments