public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { app.UseRouting(); app.UseEndpoints(endpoints => { endpoints.MapPost("/", async context => { try { using var reader = new StreamReader(context.Request.Body); var data = await reader.ReadToEndAsync(); var handler = new FunctionHandler(); var result = await handler.Handle(data); await context.Response.WriteAsync(result); } catch (Exception ex) { context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; await context.Response.WriteAsync(ex.Message); } }); }); }
static void Main(string[] args) { string buffer = getStdin(); FunctionHandler f = new FunctionHandler(); f.Handle(buffer); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Run(async(context) => { var functionHandler = new FunctionHandler(); try { var response = functionHandler.Handle(context.Request); context.Response.StatusCode = response.statusCode; foreach (KeyValuePair <string, string> entry in response.headers) { HeaderDictionaryExtensions.Append(context.Response.Headers, entry.Key, entry.Value); } await context.Response.WriteAsync(response.body); } catch (Exception ex) { Console.Write(ex); context.Response.StatusCode = (int)HttpStatusCode.InternalServerError; await context.Response.WriteAsync(ex.Message); } }); }
static void Main(string[] args) { string buffer = getStdin(); var context = new DefaultFunctionContext(); FunctionHandler f = new FunctionHandler(context); f.Handle(buffer); }
public void ExtractHtml() { var message = File.OpenText("encoded.txt").ReadToEnd(); FunctionHandler handler = new FunctionHandler(); var result = handler.Handle(message); Assert.Contains("Purchase Order 16487645-2", result); }
public void Test1() { var fh = new FunctionHandler(); var res = fh.Handle("This is my input"); var expected = "Hi there - your input was: This is my input\n"; Assert.Equal(res, expected); }
static void Main(string[] args) { string buffer = Console.In.ReadToEnd(); FunctionHandler f = new FunctionHandler(); string responseValue = f.Handle(buffer); if (responseValue != null) { Console.Write(responseValue); } }
static async Task MainAsync() { string buffer = await Console.In.ReadToEndAsync(); FunctionHandler f = new FunctionHandler(); string responseValue = await f.Handle(buffer); if (responseValue != null) { Console.Write(responseValue); } }
static void Main(string[] args) { string buffer = Console.In.ReadToEnd(); var serviceProvider = DependencyRegistrations.ConfigureServices(); FunctionHandler f = (FunctionHandler)serviceProvider.GetService(typeof(FunctionHandler)); string responseValue = f.Handle(buffer); if (responseValue != null) { Console.Write(responseValue); } }
// This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IHostingEnvironment env) { app.Run(async(context) => { var functionHandler = new FunctionHandler(); // Set up the MongoDB connection before calling the function handler. functionHandler.SetupConnection(); try { var requestBody = getRequest(context.Request.Body); var result = functionHandler.Handle(requestBody).Result; await context.Response.WriteAsync(result); } catch (Exception ex) { await context.Response.WriteAsync(ex.Message); } }); }
public void Configure(IApplicationBuilder app, IHostingEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.Run(async(context) => { var functionHandler = new FunctionHandler(); try { var requestBody = getRequest(context.Request.Body); var result = functionHandler.Handle(requestBody).Result; await context.Response.WriteAsync(result); } catch (Exception ex) { await context.Response.WriteAsync(ex.Message); } }); }
public void Handle_GetsUpperCaseString_ReturnsTheSameString() { const string input = "FOOBAR"; Assert.Equal(input, FunctionHandler.Handle(input)); }
public void Handle_GetsNotFullyUpperCaseStrings_ReturnsUpperCaseStrings(string input) { const string expected = "FOOBAR"; Assert.Equal(expected, FunctionHandler.Handle(input)); }
public async Task HandleTest() { var result = await _handler.Handle(_mockRequest.Object); Assert.Equal(System.Net.HttpStatusCode.OK, result.Status); }