mirror of
https://github.com/btcpayserver/btcpayserver.git
synced 2024-11-19 18:11:36 +01:00
29 lines
937 B
C#
29 lines
937 B
C#
using System;
|
|
using System.Linq;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace BTCPayServer.Controllers
|
|
{
|
|
public class UIErrorController : Controller
|
|
{
|
|
[Route("/errors/{statusCode:int}")]
|
|
public IActionResult Handle(int? statusCode = null)
|
|
{
|
|
if (Request.Headers.TryGetValue("Accept", out var v) && v.Any(v => v.Contains("text/html", StringComparison.OrdinalIgnoreCase)))
|
|
{
|
|
if (statusCode.HasValue)
|
|
{
|
|
var specialPages = new[] { 404, 406, 417, 429, 500, 502, 403 };
|
|
if (specialPages.Any(a => a == statusCode.Value))
|
|
{
|
|
var viewName = statusCode.ToString();
|
|
return View(viewName);
|
|
}
|
|
}
|
|
return View(statusCode);
|
|
}
|
|
return this.StatusCode(statusCode.Value);
|
|
}
|
|
}
|
|
}
|