/
qwiklly
/
cms
Обзор
Документация
Войти
/
qwiklly
/
cms
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
apps/server/Cms.App/Controllers/JsonFileController.cs
34 строки
1 KB
VildanovN
feat(#19): site api
20 ноя 2023, 13:37
20 ноя 2023, 13:37
563b6f6
Код
Авторство
О чём код?
using Cms.Services; using Microsoft.AspNetCore.Authentication.JwtBearer; using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Mvc; namespace Cms.Controllers { [ApiController] [Route("api/v0/JsonFile")] public class JsonFileController : ControllerBase { private readonly JsonFileService jsonFileService; public JsonFileController(JsonFileService jsonFileService) { this.jsonFileService = jsonFileService; } [Authorize(AuthenticationSchemes = JwtBearerDefaults.AuthenticationScheme)] [HttpGet("auth")] public ActionResult<string> GetJsonFile() { string jsonString = jsonFileService.GetJsonFile(User); return Ok(jsonString); } [HttpGet] public ActionResult<string> GetJsonFileNotAuth() { string? domain = HttpContext.Request.Headers.Host; string? jsonString = jsonFileService.GetJsonFile(null, domain); if (jsonString is null) return NotFound(); return Ok(jsonString); } } }