[][src]Module df_st_core::config

Everything related to reading, writing and parsing of the df_storyteller-config.json file.

Default configuration

{
  "local_address": "127.0.0.1",
  "server": {
    "address": "127.0.0.1",
    "port": 20350
  },
  "database":{
    "service": "sqlite",
    "config": {
      "db_path": "df_st_database.db",
      "user": "df_storyteller",
      "password": "",
      "host": "localhost",
      "port": 5432,
      "database": "df_storyteller"
    }
  }
}

The configuration file has a lot of options that can be used. Here is an example configuration example with all the possible fields:

{
  "local_address": "127.0.0.1",
  "server": {
    "address": "127.0.0.1",
    "port": 20350.
    "workers": 8,
    "keep_alive": 20,
    "log_level": "Normal",
    "secret_key": "FYyW1t+y.y+nBppoFx..$..VVVs5XrQD/yC.yHZFqZw=",
    "tls": {
      "certs": "/path/to/certs.pem",
      "private_key": "/path/to/key.pem"
    },
    "limits": {
      "forms": 5242880,
      "json": 5242880
    }
  },
  "database":{
    "service": "postgres",
    "uri": "postgres://df_storyteller:password123@localhost:5432/df_storyteller",
    "config": {
      "db_path": "df_st_database.db",
      "user": "df_storyteller",
      "password": "",
      "host": "localhost",
      "port": 5432,
      "database": "df_storyteller",
      "ssl_mode": "require",
      "ssl_cert": "~/.postgresql/server.crt",
      "ssl_key": "~/.postgresql/server.key"
    },
    "pool_size": 10
  }
}

Descriptions for all the fields can be found in the structures. The top level of the config starts in RootConfig

Structs

DBURLConfig

Everything in the configuration under df_storyteller-config.json.database.config.

DatabaseConfig

Everything in the configuration under df_storyteller-config.json.database.

LimitsConfig

Everything in the configuration under df_storyteller-config.json.server.limits.

RootConfig

The top level of the config file of df_storyteller-config.json

ServerConfig

Everything in the configuration under df_storyteller-config.json.server.

TLSConfig

Everything in the configuration under df_storyteller-config.json.server.tls.

Functions

get_config

Get a config file from disk and return the resulting configuration. If something goes wrong it will return the default configuration and output an error or warning.

get_database_url

More info about the connection URL: https://www.postgresql.org/docs/9.4/libpq-connect.html#LIBPQ-CONNSTRING

get_db_system_url

This function returns a URL to the postgres database. This is used to change general settings and create database.

store_config_to_file

Store a given configuration into a file, in json format.