mirror of
https://github.com/aljazceru/btcpayserver.git
synced 2025-12-18 22:44:29 +01:00
simplifed robots generator
This commit is contained in:
@@ -8,6 +8,8 @@ using BTCPayServer.Models;
|
||||
using NBitcoin.DataEncoders;
|
||||
using NBitcoin.Payment;
|
||||
using System.Net.Http;
|
||||
using System.Text;
|
||||
using BTCPayServer.Services;
|
||||
using Newtonsoft.Json.Linq;
|
||||
using NBitcoin;
|
||||
using Newtonsoft.Json;
|
||||
@@ -16,10 +18,12 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
public class HomeController : Controller
|
||||
{
|
||||
private readonly SettingsRepository _SettingsRepository;
|
||||
public IHttpClientFactory HttpClientFactory { get; }
|
||||
|
||||
public HomeController(IHttpClientFactory httpClientFactory)
|
||||
public HomeController(IHttpClientFactory httpClientFactory, SettingsRepository settingsRepository)
|
||||
{
|
||||
_SettingsRepository = settingsRepository;
|
||||
HttpClientFactory = httpClientFactory;
|
||||
}
|
||||
public IActionResult Index()
|
||||
@@ -103,5 +107,16 @@ namespace BTCPayServer.Controllers
|
||||
{
|
||||
return View(new ErrorViewModel { RequestId = Activity.Current?.Id ?? HttpContext.TraceIdentifier });
|
||||
}
|
||||
[Route("robots.txt")]
|
||||
public async Task<IActionResult> Robots()
|
||||
{
|
||||
var settings = await _SettingsRepository.GetSettingAsync<PoliciesSettings>();
|
||||
StringBuilder stringBuilder = new StringBuilder();
|
||||
|
||||
stringBuilder.AppendLine("user-agent: *");
|
||||
stringBuilder.AppendLine($"disallow: {(settings.DiscourageSearchEngines? "/": string.Empty)}");
|
||||
|
||||
return Content(stringBuilder.ToString(), "text/plain", Encoding.UTF8);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user