props/MultiShop/server/Controllers/PublicApiSettingsController.cs

32 lines
1.1 KiB
C#

using System.Collections.Generic;
using System.IO;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Configuration;
using MultiShop.Options;
namespace MultiShop.Server.Controllers
{
[ApiController]
[Route("api/[controller]")]
public class PublicApiSettingsController : ControllerBase
{
private IConfiguration configuration;
public PublicApiSettingsController(IConfiguration configuration)
{
this.configuration = configuration;
}
[HttpGet]
public IActionResult Get() {
return Ok(BuildPublicApiSettings());
}
private IReadOnlyDictionary<string, string> BuildPublicApiSettings() {
IdentificationOptions identificationOptions = configuration.GetSection(IdentificationOptions.Identification).Get<IdentificationOptions>();
return new Dictionary<string,string>() {
// Build dictionary containing options client should be aware of.
{"RegistrationEnabled", identificationOptions.RegistrationEnabled.ToString()}
};
}
}
}