Skip to content

Commit

Permalink
feat: add e2e tests and clean up
Browse files Browse the repository at this point in the history
- add missing env config to docs
- add main.go e2e tests for many common use cases
- add .env to non-allowed files to serve
- update .env file load only in dev add before NewWebServer
- remove app env file config
  • Loading branch information
BobyMCbobs committed Dec 23, 2023
1 parent 9559fe3 commit ac63d3c
Show file tree
Hide file tree
Showing 9 changed files with 812 additions and 95 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,5 @@
.helm
tilt_modules
.ghs.yaml

bin/
31 changes: 17 additions & 14 deletions docs/configuration.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,22 @@
# Environment variables

| Variable | Description | Default |
|-------------------------------------|---------------------------------------------------------------|------------------|
| `APP_ENV_FILE` | The location of an env file to load in, during initialisation | `.env` |
| `APP_HEALTH_PORT_ENABLED` | Enable binding of a health port | `true` |
| `APP_HEALTH_PORT` | The port to bind to for health checking | `:8081` |
| `APP_PORT` | The port to serve traffic on | `:8080` |
| `APP_METRICS_ENABLED` | Enable binding of a metrics port | `true` |
| `APP_PORT_METRICS` | The port to bind for metrics traffic | `:2112` |
| `APP_HTTP_REAL_IP_HEADER` | The HTTP header to use for real IPs | `""` |
| `APP_SERVE_FOLDER` / `KO_DATA_PATH` | The local folder path to serve | `./site` |
| `APP_TEMPLATE_MAP_PATH` | The path to a template map | `./template-map.yaml` |
| `APP_VUEJS_HISTORY_MODE` | Enable Vuejs history mode path rewriting | `false` |
| `APP_HEADER_SET_ENABLE` | Enable header setting for requests | `false` |
| `APP_HEADER_MAP_PATH` | The path to the header map | `./headers.yaml` |
| Variable | Description | Default |
|-------------------------------------|---------------------------------------------------------------|-----------------------|
| `APP_ENV_FILE` | The location of an env file to load in, during initialisation | `.env` |
| `APP_HEALTH_PORT_ENABLED` | Enable binding of a health port | `true` |
| `APP_HEALTH_PORT` | The port to bind to for health checking | `:8081` |
| `APP_PORT` | The port to serve traffic on | `:8080` |
| `APP_METRICS_ENABLED` | Enable binding of a metrics port | `true` |
| `APP_PORT_METRICS` | The port to bind for metrics traffic | `:2112` |
| `APP_HTTP_REAL_IP_HEADER` | The HTTP header to use for real IPs | `""` |
| `APP_SERVE_FOLDER` / `KO_DATA_PATH` | The local folder path to serve | `./site` |
| `APP_TEMPLATE_MAP_PATH` | The path to a template map | `./template-map.yaml` |
| `APP_VUEJS_HISTORY_MODE` | Enable Vuejs history mode path rewriting | `false` |
| `APP_HEADER_SET_ENABLE` | Enable header setting for requests | `false` |
| `APP_HEADER_MAP_PATH` | The path to the header map | `./headers.yaml` |
| `APP_REDIRECT_ROUTES_ENABLED` | Enable a map of paths to urls to redirect to | `true` |
| `APP_REDIRECT_ROUTES_PATH` | The path to a YAML file containing a map of paths to urls | `./redirects.yaml` |
| `APP_HTTP_ALLOWED_ORIGINS` | Specifies a CORS rule for allowed origin domains which can refer to this instance of go-http-server in a browser | `*` |

# Templating

Expand Down
5 changes: 3 additions & 2 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,11 @@ import (
)

func main() {
// initialise the app
log.Printf("%v (%v, %v, %v, %v)\n", common.AppName, common.AppBuildVersion, common.AppBuildHash, common.AppBuildMode, common.AppBuildDate)
if common.AppBuildMode == "development" {
_ = godotenv.Load(".env")
}
ws := ghs.NewWebServer()
_ = godotenv.Load(ws.EnvFile)
log.Printf("Configuration: %#v\n", ws)
ws.Listen()
}
Loading

0 comments on commit ac63d3c

Please sign in to comment.