2022-09-11 23:47:01 +00:00
|
|
|
using System.Collections.Generic;
|
2020-04-23 22:15:59 +00:00
|
|
|
using System.Net.Mime;
|
2022-09-11 23:47:01 +00:00
|
|
|
using Jellyfin.Api.Results;
|
2021-06-19 16:02:33 +00:00
|
|
|
using Jellyfin.Extensions.Json;
|
2019-11-23 15:31:02 +00:00
|
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
|
|
|
|
namespace Jellyfin.Api
|
|
|
|
{
|
2019-11-23 19:31:17 +00:00
|
|
|
/// <summary>
|
|
|
|
/// Base api controller for the API setting a default route.
|
|
|
|
/// </summary>
|
2019-11-23 15:31:02 +00:00
|
|
|
[ApiController]
|
|
|
|
[Route("[controller]")]
|
2020-08-20 17:17:27 +00:00
|
|
|
[Produces(
|
|
|
|
MediaTypeNames.Application.Json,
|
2020-09-03 18:15:24 +00:00
|
|
|
JsonDefaults.CamelCaseMediaType,
|
|
|
|
JsonDefaults.PascalCaseMediaType)]
|
2019-11-23 15:31:02 +00:00
|
|
|
public class BaseJellyfinApiController : ControllerBase
|
|
|
|
{
|
2022-09-11 23:47:01 +00: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<IEnumerable<T>> Ok<T>(List<T> value)
|
|
|
|
=> new OkResult<IEnumerable<T>>(value);
|
|
|
|
|
|
|
|
/// <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<IEnumerable<T>> Ok<T>(IReadOnlyList<T> value)
|
|
|
|
=> new OkResult<IEnumerable<T>>(value);
|
|
|
|
|
|
|
|
/// <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<IEnumerable<T>> Ok<T>(IEnumerable<T>? value)
|
|
|
|
=> new OkResult<IEnumerable<T>?>(value);
|
|
|
|
|
|
|
|
/// <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);
|
2019-11-23 15:31:02 +00:00
|
|
|
}
|
|
|
|
}
|