jellyfin/Jellyfin.Api/BaseJellyfinApiController.cs

38 lines
1.2 KiB
C#
Raw Normal View History

using System.Collections.Generic;
2020-04-23 15:15:59 -07:00
using System.Net.Mime;
using Jellyfin.Api.Results;
using Jellyfin.Extensions.Json;
using Microsoft.AspNetCore.Mvc;
2023-01-31 04:18:10 -07:00
namespace Jellyfin.Api;
/// <summary>
/// Base api controller for the API setting a default route.
/// </summary>
[ApiController]
[Route("[controller]")]
[Produces(
MediaTypeNames.Application.Json,
JsonDefaults.CamelCaseMediaType,
JsonDefaults.PascalCaseMediaType)]
public class BaseJellyfinApiController : ControllerBase
{
2019-11-23 12:31:17 -07:00
/// <summary>
2023-01-31 04:18:10 -07:00
/// Create a new <see cref="OkResult{T}"/>.
2019-11-23 12:31:17 -07:00
/// </summary>
2023-01-31 04:18:10 -07:00
/// <param name="value">The value to return.</param>
/// <typeparam name="T">The type to return.</typeparam>
/// <returns>The <see cref="ActionResult{T}"/>.</returns>
protected ActionResult<IEnumerable<T>> Ok<T>(IEnumerable<T>? value)
=> new OkResult<IEnumerable<T>?>(value);
2023-01-31 04:18:10 -07:00
/// <summary>
/// Create a new <see cref="OkResult{T}"/>.
/// </summary>
/// <param name="value">The value to return.</param>
/// <typeparam name="T">The type to return.</typeparam>
/// <returns>The <see cref="ActionResult{T}"/>.</returns>
protected ActionResult<T> Ok<T>(T value)
=> new OkResult<T>(value);
}