mirror of
https://github.com/yawaflua/yaflay.ru.git
synced 2025-12-18 03:26:23 +02:00
Rework controller
This commit is contained in:
36
Controllers/HomeController.cs
Normal file
36
Controllers/HomeController.cs
Normal file
@@ -0,0 +1,36 @@
|
|||||||
|
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?token=GHSAT0AAAAAAB54DYE4TFGPWCCPBHAGGZR4ZJRKIVA");
|
||||||
|
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
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -1,81 +0,0 @@
|
|||||||
using Microsoft.AspNetCore.Http;
|
|
||||||
using Microsoft.AspNetCore.Mvc;
|
|
||||||
|
|
||||||
namespace yaflay.ru.Новая_папка
|
|
||||||
{
|
|
||||||
[Route("")]
|
|
||||||
public class HomeController : Controller
|
|
||||||
{
|
|
||||||
// GET: HomeController
|
|
||||||
|
|
||||||
|
|
||||||
// GET: HomeController/Details/5
|
|
||||||
public ActionResult github()
|
|
||||||
{
|
|
||||||
return Redirect();
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: HomeController/Create
|
|
||||||
public ActionResult Create()
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST: HomeController/Create
|
|
||||||
[HttpPost]
|
|
||||||
[ValidateAntiForgeryToken]
|
|
||||||
public ActionResult Create(IFormCollection collection)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return RedirectToAction(nameof(Index));
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: HomeController/Edit/5
|
|
||||||
public ActionResult Edit(int id)
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST: HomeController/Edit/5
|
|
||||||
[HttpPost]
|
|
||||||
[ValidateAntiForgeryToken]
|
|
||||||
public ActionResult Edit(int id, IFormCollection collection)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return RedirectToAction(nameof(Index));
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// GET: HomeController/Delete/5
|
|
||||||
public ActionResult Delete(int id)
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
|
|
||||||
// POST: HomeController/Delete/5
|
|
||||||
[HttpPost]
|
|
||||||
[ValidateAntiForgeryToken]
|
|
||||||
public ActionResult Delete(int id, IFormCollection collection)
|
|
||||||
{
|
|
||||||
try
|
|
||||||
{
|
|
||||||
return RedirectToAction(nameof(Index));
|
|
||||||
}
|
|
||||||
catch
|
|
||||||
{
|
|
||||||
return View();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
Reference in New Issue
Block a user