This file contains hidden or 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
| <!-- ... --> | |
| <aspNetCore processPath="dotnet" arguments=".\Some.API.dll" stdoutLogEnabled="true" stdoutLogFile=".\logs\stdout" hostingModel="inprocess"> | |
| <handlerSettings> | |
| <handlerSetting name="debugLevel" value="file" /> | |
| <handlerSetting name="debugFile" value=".\logs\debug.log" /> | |
| </handlerSettings> | |
| </aspNetCore> | |
| <!-- ... --> |
This file contains hidden or 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
| // ... | |
| using System.Text.Json; | |
| // ... | |
| // Get properties from a JSON object | |
| // ... | |
| var contentString = await someHttpClientResponse.Content.ReadAsStringAsync(); | |
| using JsonDocument doc = JsonDocument.Parse(String.IsNullOrWhiteSpace(contentString) ? "{}" : contentString); | |
| var jsonElement = doc.RootElement.Clone(); | |
| var id = jsonElement.GetProperty("id").GetString(); |
This file contains hidden or 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
| // ... | |
| // Get a token from some external service | |
| var accessToken = await GetToken(); | |
| using var httpClient = httpClientFactory.CreateClient(); | |
| var defaultRequestHeaders = httpClient.DefaultRequestHeaders; | |
| // Accept: application/json | |
| if (defaultRequestHeaders.Accept == null || !defaultRequestHeaders.Accept.Any(m => m.MediaType == "application/json")) | |
| { |
This file contains hidden or 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 void ConfigureServices(IServiceCollection services) | |
| { | |
| // ... | |
| services.AddSingleton(new ConnectionFactory() | |
| { | |
| UserName = "guest", | |
| Password = "guest", | |
| Port = 5672, | |
| AutomaticRecoveryEnabled = true |
This file contains hidden or 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 void ConfigureServices(IServiceCollection services) | |
| { | |
| //... | |
| services.AddHttpClient("proxified") | |
| .ConfigurePrimaryHttpMessageHandler(() => | |
| { | |
| return new HttpClientHandler() | |
| { | |
| UseDefaultCredentials = true, |
This file contains hidden or 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 void ConfigureServices(IServiceCollection services) | |
| { | |
| // ... | |
| services.AddHealthChecks(); | |
| // ... | |
| } | |
| // ... |
This file contains hidden or 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 void ConfigureServices(IServiceCollection services) | |
| { | |
| // ... | |
| services.AddSwaggerDocument(config => | |
| { | |
| config.AddSecurity("x-api-key", Enumerable.Empty<string>(), new OpenApiSecurityScheme | |
| { | |
| Type = OpenApiSecuritySchemeType.ApiKey, | |
| Name = "x-api-key", |
This file contains hidden or 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 void ConfigureServices(IServiceCollection services) | |
| { | |
| // ... | |
| services.AddCors(options => | |
| { | |
| options.AddDefaultPolicy(builder => | |
| { | |
| builder.SetIsOriginAllowedToAllowWildcardSubdomains() | |
| .SetIsOriginAllowed(origin => true) |