Configuration
Rwf supports file-based and environment-based configuration. The list of configurable options are ever growing, and currently supported features are listed below.
Enabling configuration
To configure Rwf, place a file called rwf.toml
into the working directory of your app. During development, this should be the root directory of your Cargo project. At startup,
Rwf will automatically load configuration settings from that file, as they are needed by the application.
Available settings
The configuration file is using the TOML language. If you're not familiar with TOML, it's pretty simple and expressive language commonly used in the world of Rust programming.
Rwf configuration file is split into multiple sections. The [general]
section controls various options such as logging settings, and which secret key to use for encryption. The [database]
section configures database connection settings, like the database URL, connection pool size, and others.
[general]
Setting | Description | Default |
---|---|---|
log_queries |
Toggles logging of all SQL queries executed by the ORM. | false |
secret_key |
Secret key, encoded using base64, used for encryption. | Randomly generated |
cache_templates |
Toggle caching of dynamic templates. | false in debug, true in release |
Secret key
The secret key is a base64-encoded string of randomly generated data. A valid secret key contains 256 bits of entropy and must be generated using a secure random number generator.
If you have Python installed on your system, you can generate a secret key for Rwf in just a few lines of code:
[database]
Setting | Description | Default |
---|---|---|
name |
Name of the database to connect to. | Same as the $USER shell variable. If not set, default is postgres . |
user |
Name of the user to connect with to the database. | $USER , or postgres if not set. |
url |
Fully-qualified database connection string. | postgresql://{user}/localhost:5432/{name} , where {user} and {name} are name and user configuration values. |
url
The database URL was originally created by The Twelve Factor App and uses the URL format for specifying database connections. It follows a standard format, as follows:
For connecting to PostgreSQL, the driver
is postgresql
(or postgres
is also acceptable).