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 class Program | |
{ | |
public static void Main(string[] args) | |
{ | |
CreateWebHostBuilder(args).Build().Run(); | |
} | |
public static IWebHostBuilder CreateWebHostBuilder(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.UseStartup<Startup>(); | |
} |
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 IWebHost BuildWebHost(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.UseStartup<Startup>() | |
.ConfigureAppConfiguration((builderContext, config) => | |
{ | |
var env = hostingContext.HostingEnvironment; | |
var builtConfig = config.Build(); | |
var vaultUrl = $"https://{buiItConfig["VaultName"]}.vault.azure.net/"; | |
if (env.IsDevelopment()) |
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 IWebHost BuildWebHost(string[] args) => | |
WebHost.CreateDefaultBuilder(args) | |
.UseStartup<Startup>() | |
.ConfigureAppConfiguration((builderContext, config) => | |
{ | |
var builtConfig = config.Build(); | |
var vaultUrl = $"https://{buiItConfig["VaultName"]}.vault.azure.net/"; | |
config.AddAzureKeyVault(vaultUrl); | |
}); |
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
#### List of start wars planets | |
GET https://swapi.co/api/planets/ HTTP/1.1 | |
### Get Luke Skywalker | |
# @name lukeRequest | |
GET https://swapi.co/api/people/?search=Luke HTTP/1.1 | |
### Get Luke Skywalker home planet | |
GET {{lukeRequest.response.body.results[0].homeworld}} HTTP/1.1 |
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
#r "nuget: Handlebars.Net, 1.9.5" | |
using HandlebarsDotNet; | |
string html = @" | |
<ul class=""people""> | |
{{#each people}} | |
<li>{{FirstName}} {{LastName}} - {{Job}}</li> | |
{{/each}} | |
</ul>"; |
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 class UserService : IUserService | |
{ | |
private readonly HttpClient _httpClient; | |
public UserService(HttpClient httpClient) | |
{ | |
_httpClient = httpClient; | |
} | |
public async Task<IReadOnlyCollection<User>> GetAllUsers() | |
{ |
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 class UserApiAuthenticationService : IUserApiAuthenticationService | |
{ | |
private readonly IMemoryCache _memoryCache; | |
private readonly HttpClient _httpClient; | |
public UserApiAuthenticationService(HttpClient httpClient, IMemoryCache memoryCache) | |
{ | |
_httpClient = httpClient; | |
_memoryCache = memoryCache; | |
} |
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 class UserApiAuthenticationHandler : DelegatingHandler | |
{ | |
private readonly IUserApiAuthenticationService _authenticationService; | |
public UserApiAuthenticationHandler(IUserApiAuthenticationService authenticationService) | |
{ | |
_authenticationService = authenticationService; | |
} | |
protected async override Task<HttpResponseMessage> SendAsync(HttpRequestMessage request, CancellationTokencancellationToken) |
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 class UserService : | |
{ | |
private readonly HttpClient _httpClient; | |
public UserService(HttpClient httpClient) | |
{ | |
_httpClient = httpClient; | |
} | |
public async Task<IReadOnlyCollection<User>> GetAllUsers() | |
{ |
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
var body = new { login = "login", password = "password" }; | |
var response = await _httpClient.PostAsync("login", new StringContent(JsonConvert.SerializeObject(body))); | |
var authResponse = await response.Content.ReadAsAsync<AuthResponse>(); |
OlderNewer