Skip to content

Configuration Parameters

MARS configuration is a name/value store (TMARSParameters) available at the engine and application levels. Values are typically loaded from an .ini file next to the executable with FEngine.Parameters.LoadFromIniFile, and can be read in code or injected with [EngineParam] / [ApplicationParam].

ini
[Engine]
Port=8080
ThreadPoolSize=75
BasePath=/rest

[DefaultApp]
JWT.Secret=please-change-me
JWT.Duration=1

When AddApplication runs, the engine copies the matching .ini section (by application name) into the application's parameters.

Engine parameters

ParameterTypeDefaultPurpose
PortInteger8080HTTP listening port.
PortSSLInteger0HTTPS port (0 = disabled).
ThreadPoolSizeInteger75Worker threads (size for concurrent requests, incl. open SSE streams).
BasePathstring/restRoot path stripped from every URL before application matching.

CORS-related parameters (when CORS is enabled) include CORS.Origin, CORS.Methods, CORS.Headers. See Engine ▸ CORS.

JWT / authentication parameters (per application)

Read by the token resource and JWT backends:

ParameterDefaultPurpose
JWT.Secret(a fixed GUID — change it!)HMAC signing secret.
JWT.IssuerMARS-Curiosityiss claim.
JWT.Duration1Token lifetime in days.
JWT.Duration.InMinutesLifetime in minutes (alternative).
JWT.Duration.InSecondsLifetime in seconds (alternative).
JWT.CookieEnabledtrueAlso deliver/accept the token as a cookie.
JWT.CookieNameaccess_tokenCookie name.
JWT.CookieDomainCookie domain.
JWT.CookiePathCookie path.
JWT.CookieSecurefalseMark the cookie Secure (HTTPS only).

Change JWT.Secret

The default secret ships in the public source. Always set a strong, unique secret per deployment.

FireDAC parameters

Connection definitions live under a slice (commonly FireDAC) and are loaded with TMARSFireDAC.LoadConnectionDefs(FEngine.Parameters, 'FireDAC'). Each named definition maps to a FireDAC ConnectionDefName with its usual driver-specific keys (DriverID, Database, Server, User_Name, Password, pooling options, …). See FireDAC & Datasets.

Reading and injecting parameters

pascal
// In code
var LPort := FEngine.Parameters.ByName('Port').AsInteger;
var LSecret := LApp.Parameters.ByName('JWT.Secret').AsString;

// Injected into a resource
[Path('cfg')]
TCfgResource = class
  [EngineParam('Port', 8080)]       Port: Integer;
  [ApplicationParam('JWT.Secret')]  Secret: string;
end;

Provide a default as the second argument to ByName/[EngineParam]/[ApplicationParam] so missing keys degrade gracefully.

Custom parameters

You can add your own keys to the .ini and read/inject them the same way — a convenient place for feature flags, external service URLs, file paths, etc.

ini
[DefaultApp]
Feature.NewSearch=true
Storage.Path=C:\data\uploads
pascal
[ApplicationParam('Storage.Path')] StoragePath: string;

Released under the Apache License 2.0.