add logging; fix caching
[pharext/pharext.org] / app / bootstrap / github.php
index 55a49a7298034c614976be6340a4df296d7f0f6c..30bd96d88727decc1a97de18e7eafa77396e2925 100644 (file)
@@ -4,14 +4,25 @@ namespace app;
 
 require_once __DIR__."/config.php";
 
-use merry\Config;
+use http\Url;
 
 $injector->share(Github\API::class)
        ->delegate(Github\API::class, function() use($injector) {
+               $config = $injector->make(Config::class);
+               if (isset($config->github->hook->use_basic_auth)) {
+                       $basic = $config->github->hook->use_basic_auth;
+                       $config->github->hook->url = (string) new Url(
+                               $config->github->hook->url,
+                               $config->$basic->auth->toArray(),
+                               0);
+               }
+               // FIXME: configure through app.ini
                return new Github\API(
-                       $injector->make(Config::class)->github
-                  ,new Github\Storage\Session("gh-tokens")
+                        $config->github
+                       ,new Github\Logger($config)
+                       ,new Github\Storage\Session("gh-tokens")
                   #,new Github\Storage\Memcache("gh-cache")
+                       ,new Github\Storage\Redis("gh-cache")
           );
        });