Ejemplo n.º 1
0
        public ApiController(AppService appService, ConfigurationService configurationService)
            : base(ApiRoot)
        {
            _logger = LogManager.GetLogger(typeof(ApiController));

            _appService           = appService;
            _configurationService = configurationService;

            Get["/apps"] = x =>
            {
                var apps        = _appService.InitedApps();
                var installPath = _configurationService.DeploymentPath();
                return(Response.AsJson(new { installPath, total = apps.Count, apps }));
            };

            Get["/apps/{AppName}"] = x =>
            {
                var appName        = (string)x.AppName;
                var backupVersions = _appService.AvailableBackupVersions(appName);
                var version        = _appService.InstalledVersion(appName);
                return(Response.AsJson(new { appName, version, backupVersions }));
            };

            Post["/install-queue/{AppName}"] = x =>
            {
                string environment   = Request.Query["environment"];
                bool   prepareOnly   = Request.Query["prepareOnly"] != null;
                bool   forceDownload = Request.Query["forceDownload"] != null;
                _logger.DebugFormat("Install {0} ({1})", x.AppName, environment);
                _appService.InstallPackage((string)x.AppName, prepareOnly, forceDownload, environment);
                var response = new { next = ApiRoot + "/apps/" + x.AppName };
                return(Response.AsJson(response, HttpStatusCode.Created));
            };
        }
Ejemplo n.º 2
0
 public HomeController(AppService appService, ConfigurationService configurationService)
 {
     Get["/"]     = x => Response.AsText("deployd watchman");
     Get["/apps"] = x =>
     {
         var apps        = appService.InitedApps();
         var installPath = configurationService.DeploymentPath();
         var viewModel   = new AppsViewModel();
         viewModel.Apps        = apps;
         viewModel.InstallPath = installPath;
         return(Negotiate.WithModel(viewModel).WithView("apps.cshtml"));
     };
     Get["/apps/{appName}"] = x =>
     {
         var appName        = (string)x.AppName;
         var backupVersions = appService.AvailableBackupVersions(appName);
         var version        = appService.InstalledVersion(appName);
         var viewModel      = new AppViewModel();
         viewModel.AppName        = appName;
         viewModel.BackupVersions = backupVersions;
         viewModel.Version        = version;
         return(Negotiate.WithModel(viewModel).WithView("app.cshtml"));
     };
 }