From d6c419e124a9ed0ee666b5debd3d37addd6f3364 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=94=D0=BC=D0=B8=D1=82=D1=80=D0=B8=D0=B9=20=D0=A8=D0=B8?= =?UTF-8?q?=D0=BC=D0=B0=D0=BD=D1=81=D0=BA=D0=B8=D0=B9?= Date: Thu, 19 Oct 2023 19:14:19 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9A=D1=80=D0=B0=D1=81=D0=B8=D0=B2=D0=BE=20?= =?UTF-8?q?=D1=80=D0=B5=D0=B0=D0=BB=D0=B8=D0=B7=D0=BE=D0=B2=D0=B0=D0=BB=20?= =?UTF-8?q?=D0=B2=D1=81=D0=B5=20=D1=87=D1=82=D0=BE=20=D0=BD=D0=B0=D0=B4?= =?UTF-8?q?=D0=BE=20=D0=B8=20=D0=BA=D1=80=D0=B0=D1=81=D0=B8=D0=B2=D0=BE=20?= =?UTF-8?q?=D0=B8=D1=81=D0=BF=D1=80=D0=B0=D0=B2=D0=B8=D0=BB=20=D0=BE=D1=88?= =?UTF-8?q?=D0=B8=D0=B1=D0=BA=D0=B8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Controllers/HomeController.cs | 28 ++++++++++++++++++---------- 1 file changed, 18 insertions(+), 10 deletions(-) diff --git a/Controllers/HomeController.cs b/Controllers/HomeController.cs index f5e3a2a..1894b76 100644 --- a/Controllers/HomeController.cs +++ b/Controllers/HomeController.cs @@ -15,20 +15,28 @@ namespace yaflay.ru.Новая_папка private async Task getUrlFromGit(string baseUrl) { - HttpClient client = new(); - string Base64BearerToken = Convert.ToBase64String(Encoding.UTF8.GetBytes("")); - client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", Base64BearerToken); - HttpResponseMessage getter = await client.GetAsync("https://raw.githubusercontent.com/YaFlay/yaflay.ru/master/redirect_uris.json"); - JsonNode allFile = JsonNode.Parse(await getter.Content.ReadAsStringAsync()); - return (string?)allFile[baseUrl]; + try + { + HttpClient client = new(); + HttpResponseMessage getter = await client.GetAsync("https://raw.githubusercontent.com/YaFlay/yaflay.ru/master/redirect_uris.json"); + await Console.Out.WriteLineAsync(await getter.Content.ReadAsStringAsync()); + JsonNode allFile = JsonNode.Parse(await getter.Content.ReadAsStringAsync()); + return (string?)allFile[baseUrl]; + } + catch (Exception except) + { + await Console.Out.WriteLineAsync(except.ToString()); + return null; + } } // GET: HomeController/Details/5 - [HttpGet] - public async Task fromGitHub() + [HttpGet("/{uri}")] + public async Task fromGitHub(string? uri) { - string? url = await getUrlFromGit(HttpContext.Request.Path.Value); + if (uri == null) { return View("Index.cshtml"); } + string? url = await getUrlFromGit(uri); - return Redirect(url != null ? url : "yaflay.ru"); + return Redirect(url != null ? url : "https://yaflay.ru/"); } // GET: HomeController/Create