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.

Which .ini file is used ​

LoadFromIniFile (and SaveToIniFile / IniFileExists) accept an explicit file name. Called without one, they resolve it in this order:

  1. the -configFileName <path> command-line switch, if present — handy to run the same binary against different configurations (dev, staging, service instances);
  2. otherwise the module name with the extension changed to .ini — MyServer.exe → MyServer.ini, an ISAPI DLL → <dllname>.ini.

Parameters.GetFileName returns the path that would be used, with the same rules, which is what to log or display when a server starts up with unexpected settings:

pascal
if not FEngine.Parameters.IniFileExists then
  Writeln('No configuration file at ' + FEngine.Parameters.GetFileName);

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—HMAC signing secret. Missing or equal to the public default: see JWT.AllowDefaultSecret.
JWT.AllowDefaultSecretfalseKnowingly use the public default secret. Otherwise a DEBUG build generates a random per-process secret and a RELEASE build raises (TMARSToken.DefaultSecretPolicy).
JWT.IssuerMARS-Curiosityiss claim.
JWT.Duration1Token lifetime in days.
JWT.Duration.InMinutes—Lifetime in minutes (alternative).
JWT.Duration.InSeconds—Lifetime in seconds (alternative).
JWT.CookieEnabledtrueAlso deliver/accept the token as a cookie.
JWT.CookieNameaccess_tokenCookie name.
JWT.CookieDomain—Cookie domain.
JWT.CookiePath—Cookie path.
JWT.CookieSecurefalseMark the cookie Secure (HTTPS only).

Set JWT.Secret

The default secret ships in the public source and is never used unless you opt in with JWT.AllowDefaultSecret. Set a strong, unique secret per deployment; MARSCmd writes a random one into the .ini files of every project it creates.

Logging parameters ​

Read by the request/response loggers (engine section). Each logger is inert until both its unit is in the server's uses clause and its Enabled flag is set.

ParameterTypeDefaultPurpose
JSONLogging.EnabledBooleanFalseEnable the NDJSON file logger (MARS.Utils.ReqRespLogger.JSON).
MemoryLogging.EnabledBooleanFalseEnable the in-memory logger (MARS.Utils.ReqRespLogger.Memory); it retains whole requests and responses in clear text.
JSONLogging.Folderstring<exe folder>\logsTarget directory (created if missing).
JSONLogging.FileNamestringmars-reqresp.logBase log file name.
JSONLogging.DailyRotationBooleanTrueInsert the date before the extension for daily rotation.
CodeSiteLogging.EnabledBooleanFalseEnable CodeSite output (MARS.Utils.ReqRespLogger.CodeSite).

See Request/Response Logging for the log line format and a Grafana Alloy ingestion example.

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.