This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Defined separately from the grain, this reducer can be taken out and shared with | |
// a Xamarin / XAML app using Redux.NET as the clientside store | |
public static CounterState Reducer(CounterState state, IAction action) | |
{ | |
switch (action) | |
{ | |
case IncrementCounterAction a: | |
return new CounterState(state) { Count = (state?.Count ?? 0) + 1 }; | |
case DecrementCounterAction a: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[HttpPost("~/incrementcounter")] | |
public async Task<ActionResult> IncrementCounter() | |
{ | |
var grain = GrainClient.GrainFactory.GetGrain<ICounterGrain>(this.sessionId); | |
await grain.IncrementCounter(); | |
return Ok(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
async function postEffect(url: string, xsrfToken: string, data: any = {}) { | |
let response = await fetch(url, { | |
method: 'POST', | |
credentials: 'include', | |
headers: { | |
'Content-Type': 'application/json', | |
'X-XSRF-TOKEN': xsrfToken | |
}, | |
body: JSON.stringify(data) | |
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"AcmeSettings": { | |
"PfxPassword": "yoursupersecretpassword", | |
"EmailAddress": "[email protected]" | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{ | |
"urls": "https://06478ca8.ngrok.io", | |
"ConnectionStrings": { | |
"DataConnectionString": "UseDevelopmentStorage=true" | |
}, | |
"Logging": { | |
"IncludeScopes": false, | |
"LogLevel": { | |
"Default": "Debug", | |
"System": "Information", |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static string GetAddHostNamePortCertCommand(string hostname, int port, string thumbprint) | |
{ | |
return $"netsh http add sslcert hostnameport={hostname}:{port} certhash={thumbprint} appid={Guid.Empty.ToString("B")} certstorename=MY"; | |
} | |
public static string GetDeleteHostNamePortCertCommand(string hostname, int port) | |
{ | |
return $"netsh http delete sslcert hostnameport={hostname}:{port}"; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
.UseKestrel(async options => { | |
if (secureUrls.Any()) | |
{ | |
var certificateManager = options.ApplicationServices.GetService<ICertificateManager>(); | |
var certificate = await certificateManager.GetCertificate(httpsDomains); | |
if (certificate != null) | |
options.UseHttps(certificate); | |
} | |
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Register a certitificate manager, supplying methods to store and retreive certificates and acme challenge responses | |
services.AddAcmeCertificateManager(options => { | |
options.DomainNames = httpsDomains; | |
options.GetChallengeResponse = async (challenge) => | |
{ | |
var cacheGrain = GrainClient.GrainFactory.GetGrain<ICacheGrain<string>>(challenge); | |
var response = await cacheGrain.Get(); | |
return response.Value; | |
}; | |
options.SetChallengeResponse = async (challenge, response) => |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
acmeHost = new WebHostBuilder() | |
[...] | |
.Configure(app => { | |
app.UseAcmeResponse(); | |
}) | |
.Build(); | |
acmeHost.Start(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
X509Certificate2 certificate = [some certificate including key]; | |
var host = new WebHostBuilder() | |
.UseKestrel(options => options.UseHttps(certificate)) | |
.UseContentRoot(Directory.GetCurrentDirectory()) | |
.UseIISIntegration() | |
.UseStartup<Startup>() | |
.Build(); | |
host.Run(); |