mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2025-12-16 18:46:26 +02:00
37 lines
1.2 KiB
C#
37 lines
1.2 KiB
C#
using Microsoft.AspNetCore.Http;
|
||
using Microsoft.AspNetCore.Mvc;
|
||
using System.Net;
|
||
using System.Net.Http.Headers;
|
||
using System.Text;
|
||
using System.Text.Json.Nodes;
|
||
using System.Xml.Schema;
|
||
|
||
namespace yaflay.ru.Новая_папка
|
||
{
|
||
[Route("")]
|
||
public class HomeController : Controller
|
||
{
|
||
// GET: HomeController
|
||
|
||
private async Task<string> 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];
|
||
}
|
||
// GET: HomeController/Details/5
|
||
[HttpGet]
|
||
public async Task<IActionResult> fromGitHub()
|
||
{
|
||
string? url = await getUrlFromGit(HttpContext.Request.Path.Value);
|
||
|
||
return Redirect(url != null ? url : "yaflay.ru");
|
||
}
|
||
|
||
// GET: HomeController/Create
|
||
}
|
||
}
|