From 8253ca8cb96154f95854b1c1e5dd3ba53f41e5ec Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 14 Aug 2023 19:45:52 +0200 Subject: Code cleanup --- MxApiExtensions/Program.cs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) (limited to 'MxApiExtensions/Program.cs') diff --git a/MxApiExtensions/Program.cs b/MxApiExtensions/Program.cs index 00afe09..11fe114 100644 --- a/MxApiExtensions/Program.cs +++ b/MxApiExtensions/Program.cs @@ -1,3 +1,4 @@ +using Microsoft.AspNetCore.Http.Timeouts; using MxApiExtensions; var builder = WebApplication.CreateBuilder(args); @@ -15,13 +16,13 @@ builder.Services.AddSingleton(); builder.Services.AddScoped(); builder.Services.AddRequestTimeouts(x => { - x.DefaultPolicy = new() { + x.DefaultPolicy = new RequestTimeoutPolicy { Timeout = TimeSpan.FromMinutes(10), WriteTimeoutResponse = async context => { context.Response.StatusCode = 504; context.Response.ContentType = "application/json"; await context.Response.StartAsync(); - await context.Response.WriteAsJsonAsync(new MatrixException() { + await context.Response.WriteAsJsonAsync(new MatrixException { ErrorCode = "M_TIMEOUT", Error = "Request timed out" }.GetAsJson()); -- cgit 1.5.1