Created
March 16, 2022 09:52
-
-
Save neuecc/b2e3acbb0b488af6fdb9889ee73f585c to your computer and use it in GitHub Desktop.
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 DFrame; | |
| using Microsoft.Extensions.DependencyInjection; | |
| // use builder can configure services, logging, configuration, etc. | |
| var builder = DFrameApp.CreateBuilder(7312, 7313); | |
| builder.ConfigureServices(services => | |
| { | |
| services.AddSingleton<HttpClient>(); | |
| }); | |
| await builder.RunAsync(); | |
| public class HttpGetString : Workload | |
| { | |
| readonly HttpClient httpClient; | |
| readonly string url; | |
| // HttpClient is from DI, URL is passed from Web UI | |
| public HttpGetString(HttpClient httpClient, string url) | |
| { | |
| this.httpClient = httpClient; | |
| this.url = url; | |
| } | |
| public override async Task ExecuteAsync(WorkloadContext context) | |
| { | |
| await httpClient.GetStringAsync(url, context.CancellationToken); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment