From 8253ca8cb96154f95854b1c1e5dd3ba53f41e5ec Mon Sep 17 00:00:00 2001 From: TheArcaneBrony Date: Mon, 14 Aug 2023 19:45:52 +0200 Subject: Code cleanup --- MxApiExtensions/Controllers/GenericProxyController.cs | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'MxApiExtensions/Controllers/GenericProxyController.cs') diff --git a/MxApiExtensions/Controllers/GenericProxyController.cs b/MxApiExtensions/Controllers/GenericProxyController.cs index 91ae55a..f0ad4e7 100644 --- a/MxApiExtensions/Controllers/GenericProxyController.cs +++ b/MxApiExtensions/Controllers/GenericProxyController.cs @@ -4,7 +4,7 @@ using Microsoft.AspNetCore.Mvc; namespace MxApiExtensions.Controllers; [ApiController] -[Route("/")] +[Route("/{*_}")] public class GenericController : ControllerBase { private readonly ILogger _logger; private readonly CacheConfiguration _config; @@ -17,13 +17,13 @@ public class GenericController : ControllerBase { _auth = auth; } - [HttpGet("{*_}")] + [HttpGet] public async Task Proxy([FromQuery] string? access_token, string _) { try { access_token ??= _auth.GetToken(fail: false); var mxid = _auth.GetUserId(fail: false); - _logger.LogInformation($"Proxying request for {mxid}: {Request.Path}{Request.QueryString}"); + _logger.LogInformation("Proxying request for {}: {}{}", mxid, Request.Path, Request.QueryString); using var hc = new HttpClient(); hc.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", access_token); @@ -71,13 +71,13 @@ public class GenericController : ControllerBase { } } - [HttpPost("{*_}")] + [HttpPost] public async Task ProxyPost([FromQuery] string? access_token, string _) { try { access_token ??= _auth.GetToken(fail: false); var mxid = _auth.GetUserId(fail: false); - _logger.LogInformation($"Proxying request for {mxid}: {Request.Path}{Request.QueryString}"); + _logger.LogInformation("Proxying request for {}: {}{}", mxid, Request.Path, Request.QueryString); using var hc = new HttpClient(); hc.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", access_token); @@ -89,10 +89,10 @@ public class GenericController : ControllerBase { .Replace($"access_token={access_token}", "") ); - var resp = await hc.SendAsync(new() { + var resp = await hc.SendAsync(new HttpRequestMessage { Method = HttpMethod.Post, RequestUri = new Uri($"{_config.Homeserver}{Request.Path}{Request.QueryString}"), - Content = new StreamContent(Request.Body), + Content = new StreamContent(Request.Body) }); if (resp.Content is null) { -- cgit 1.5.1