public GrainController(Router router, TaskScheduler taskScheduler, IProviderRuntime providerRuntime) { this.TaskScheduler = taskScheduler; this.ProviderRuntime = providerRuntime; Action<string, Func<IOwinContext, IDictionary<string, string>, Task>> add = router.Add; add("/grain/:type/:id/:method", CallGrain); add("/grain/:type/:id/:method/:classprefix", CallGrain); add("/pinggrain", PingGrain); add("/ping", Ping); }
public Task Init(string name, IProviderRuntime providerRuntime, IProviderConfiguration config) { this.logger = providerRuntime.GetLogger(name); this.Name = name; var router = new Router(); new GrainController(router, TaskScheduler.Current, providerRuntime); var options = new StartOptions { ServerFactory = "Nowin", Port = config.Properties.ContainsKey("Port") ? int.Parse(config.Properties["Port"]) : 8080, }; var username = config.Properties.ContainsKey("Username") ? config.Properties["Username"] : null; var password = config.Properties.ContainsKey("Password") ? config.Properties["Password"] : null; host = WebApp.Start(options, app => new WebServer(router, username, password).Configure(app)); this.logger.Verbose($"HTTP API listening on {options.Port}"); return Task.FromResult(0); }
public WebServer(Router router, string username, string password) { this.Router = router; this.Username = username; this.Password = password; }