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.
57 lines
2.1 KiB
57 lines
2.1 KiB
using System.Collections.Generic;
|
|
using System.Net.Mime;
|
|
using Jellyfin.Api.Results;
|
|
using Jellyfin.Extensions.Json;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
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
|
|
{
|
|
/// <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);
|
|
}
|
|
}
|