mirage-injector/examples/quickstart/app.d

38 lines
856 B
D
Raw Permalink Normal View History

2022-11-27 16:47:33 +01:00
/**
2023-02-20 19:29:31 +01:00
* Authors:
* Mike Bierlee, m.bierlee@lostmoment.com
* Copyright: 2022-2023 Mike Bierlee
* License:
* This software is licensed under the terms of the MIT license.
* The full terms of the license can be found in the LICENSE.txt file.
2022-11-27 16:47:33 +01:00
*/
module examples.quickstart.app;
import poodinis : DependencyContainer, Value;
import poodinis.valueinjector.mirage : loadConfig;
import std.stdio : writeln;
import std.conv : to;
2023-03-07 00:27:21 +01:00
class Server {
2022-11-27 16:47:33 +01:00
@Value("server.host")
private string host;
@Value("server.port")
private int port;
2023-03-07 00:27:21 +01:00
public void run() {
2022-11-27 16:47:33 +01:00
writeln("Running server on " ~ host ~ ":" ~ port.to!string);
}
}
2023-03-07 00:27:21 +01:00
void main() {
2022-11-27 16:47:33 +01:00
auto container = new shared DependencyContainer();
container.register!Server;
container.loadConfig("config.ini");
auto server = container.resolve!Server;
server.run();
}