Question about vibe.conf file

crimaniak via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Sun Mar 5 08:54:56 PST 2017


On Sunday, 5 March 2017 at 13:41:23 UTC, Suliman wrote:
> I had seen some mentions about `vibe.conf` file in vibed docs. 
> But can't understand it's structure and find examples of it's 
> usage.

Json file. Real example:
```
{
	"mqttHost"       : "***.***.**.***",
	"mqttPort"       : 1883,
	"mqttClientName" : "*****",
	"mqttUsername"   : "*****",
	"mqttPassword"   : "*****",
	
	"listenInterface": "127.0.0.1",
	"listenPort"     : 8088,
	
	"dbConnection"   : "host=127.0.0.1;user=root;pwd=;db=dbname"
}
```

You can read values from it like this:

```
// Read http setting from vibe.conf and init session store
HTTPServerSettings prepareHttpSettings()
{
	auto settings = new HTTPServerSettings;
	settings.port = readRequiredOption!ushort("listenPort","Port to 
listen by internal HTTP server");
	settings.bindAddresses = 
[readRequiredOption!string("listenInterface", "Interface to 
listen by internal HTTP server")];
	settings.sessionStore = new MemorySessionStore;
	
	return settings;
}
```


More information about the Digitalmars-d-learn mailing list