mirror of
https://github.com/QuotifyTeam/QuotifyBE.git
synced 2025-12-16 19:20:06 +01:00
feat: experimental cors support
This commit is contained in:
@@ -1,11 +1,12 @@
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Cors;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using QuotifyBE.Data;
|
||||
using QuotifyBE.DTOs;
|
||||
using QuotifyBE.Entities;
|
||||
using QuotifyBE.Mapping;
|
||||
using System.Security.Claims;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace QuotifyBE.Controllers;
|
||||
|
||||
@@ -29,12 +30,17 @@ public class QuotesController : ControllerBase
|
||||
/// <summary>
|
||||
/// Get a page of quotes
|
||||
/// </summary>
|
||||
/// <remarks>A page of quotes consists of 10 quotes or less. If a page does not contain any quotes, 404 is returned.</remarks>
|
||||
/// <remarks>
|
||||
/// A page of quotes consists of 10 quotes or less.
|
||||
/// If a page does not contain any quotes, 404 is returned.
|
||||
/// Important! Has CORS set, unlike e.g. GET /api/v1/quote/{id} or GET /api/v1/quote/random.
|
||||
/// </remarks>
|
||||
/// <param name="page_no">The page number</param>
|
||||
/// <returns>A page (10 quotes)</returns>
|
||||
/// <response code="200">Returned on valid request</response>
|
||||
/// <response code="404">Returned when requested page is invalid</response>
|
||||
[HttpGet("page/{page_no}")]
|
||||
[EnableCors]
|
||||
[ProducesResponseType(typeof(List<QuoteShortDTO>), 200)]
|
||||
[ProducesResponseType(typeof(ErrorDTO), 404)]
|
||||
public async Task<IActionResult> GetQuotePage(int page_no)
|
||||
@@ -102,6 +108,7 @@ public class QuotesController : ControllerBase
|
||||
/// <response code="403">Returned when user's id does not match the creator's id</response>
|
||||
[HttpPost("new")]
|
||||
[Authorize]
|
||||
[EnableCors]
|
||||
[ProducesResponseType(201)] // ? FIXME
|
||||
[ProducesResponseType(typeof(ErrorDTO), 400)]
|
||||
[ProducesResponseType(typeof(ErrorDTO), 403)]
|
||||
|
||||
Reference in New Issue
Block a user