Skip to content

Top-Level Settings

These settings configure the application identity, server binding, and configuration behavior.

Application Settings

json
{
  "ApplicationName": null,
  "EnvironmentName": "Production",
  "Urls": "http://localhost:8080",
  "StartupMessage": "Started in {time}, listening on {urls}, version {version}"
}

Settings Reference

SettingTypeDefaultDescription
ApplicationNamestringnullApplication identifier. Defaults to the top-level directory name if not set.
EnvironmentNamestring"Production"Environment designation (Development, Staging, Production).
Urlsstring"http://localhost:8080"Server listening URLs. Separate multiple URLs with semicolons.
StartupMessagestring(see below)Message displayed on startup. Supports placeholders.

Default StartupMessage: "Started in {time}, listening on {urls}, version {version}"

Urls Configuration

The Urls setting accepts multiple URLs separated by semicolons:

json
{
  "Urls": "http://localhost:8080;https://localhost:8443"
}

To listen on all interfaces:

json
{
  "Urls": "http://0.0.0.0:8080;https://0.0.0.0:8443"
}

Startup Message Placeholders

Customize the startup message with these placeholders:

PlaceholderDescription
{time}Startup time
{urls}Listening URLs
{version}Application version
{environment}Environment name (from EnvironmentName)
{application}Application name (from ApplicationName)

Example:

json
{
  "StartupMessage": "Started in {time}, listening on {urls}, version {version}, env: {environment}"
}

Config Section

The Config section controls how the configuration file itself is processed.

json
{
  "Config": {
    "ExposeAsEndpoint": null,
    "AddEnvironmentVariables": false,
    "ParseEnvironmentVariables": true
  }
}

Settings Reference

SettingTypeDefaultDescription
ExposeAsEndpointstringnullExpose current configuration to an endpoint for debugging. Set to a path like "/config" to enable. Passwords in connection strings are not exposed.
AddEnvironmentVariablesboolfalseAllow environment variables to override configuration settings.
ParseEnvironmentVariablesbooltrueParse {ENV_VAR_NAME} placeholders in config values and replace with environment variable values.

Environment Variable Override

When AddEnvironmentVariables is true, environment variables can override any configuration setting. Use double underscores for nested keys:

bash
# Override ConnectionStrings.Default
export ConnectionStrings__Default="Host=production-server;..."

# Override NpgsqlRest.UrlPathPrefix
export NpgsqlRest__UrlPathPrefix="/v2/api"

Environment Variable Parsing

When ParseEnvironmentVariables is true (default), you can use {ENV_VAR} syntax anywhere in configuration values:

json
{
  "ConnectionStrings": {
    "Default": "Host={PGHOST};Port={PGPORT};Database={PGDATABASE};Username={PGUSER};Password={PGPASSWORD}"
  }
}

This allows sensitive values to be kept in environment variables rather than in the configuration file.

Exposing Configuration

For debugging purposes, you can expose the current configuration as an endpoint:

json
{
  "Config": {
    "ExposeAsEndpoint": "/config"
  }
}

This creates a GET /config endpoint that returns the current configuration as JSON. Passwords in connection strings are automatically redacted.

Next Steps

Released under the MIT License.