You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
PortfolioLink/backend/Controllers/TemplateConfigController.cs

36 lines
1.1 KiB

using Microsoft.AspNetCore.Mvc;
using backend.Models;
using Newtonsoft.Json;
using Microsoft.AspNetCore.Cors;
namespace backend.Controllers
{
[Route("api/template")]
[ApiController]
public class TemplateConfigController : ControllerBase
{
private readonly IConfiguration _config;
public TemplateConfigController(IConfiguration configuration)
{
_config = configuration;
}
[HttpGet]
public ActionResult<string> Get()
{
Console.WriteLine("template get triggered");
List<HeaderTemplate>? templateHeaders = _config.GetSection("templateHeaders").Get<List<HeaderTemplate>>();
bool? validateData = _config.GetSection("validateData").Get<bool>();
if (templateHeaders == null || validateData == null)
{
return "Failed to retreieve template config!";
}
TemplateConfiguration templateConfig = new TemplateConfiguration(validateData ?? true, templateHeaders);
return JsonConvert.SerializeObject(templateConfig);
}
}
}