Prepare plugin Api migration

pull/3871/head
David 5 years ago
parent 75f119b57f
commit 98d1d2325d

@ -18,7 +18,10 @@ using Jellyfin.Api.Constants;
using Jellyfin.Api.Controllers; using Jellyfin.Api.Controllers;
using Jellyfin.Server.Formatters; using Jellyfin.Server.Formatters;
using Jellyfin.Server.Models; using Jellyfin.Server.Models;
using MediaBrowser.Common;
using MediaBrowser.Common.Json; using MediaBrowser.Common.Json;
using MediaBrowser.Common.Plugins;
using MediaBrowser.Controller;
using MediaBrowser.Model.Entities; using MediaBrowser.Model.Entities;
using Microsoft.AspNetCore.Authentication; using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Authorization; using Microsoft.AspNetCore.Authorization;
@ -135,10 +138,11 @@ namespace Jellyfin.Server.Extensions
/// </summary> /// </summary>
/// <param name="serviceCollection">The service collection.</param> /// <param name="serviceCollection">The service collection.</param>
/// <param name="baseUrl">The base url for the API.</param> /// <param name="baseUrl">The base url for the API.</param>
/// <param name="applicationHost">The application host.</param>
/// <returns>The MVC builder.</returns> /// <returns>The MVC builder.</returns>
public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl) public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl, IApplicationHost applicationHost)
{ {
return serviceCollection IMvcBuilder mvcBuilder = serviceCollection
.AddCors(options => .AddCors(options =>
{ {
options.AddPolicy(ServerCorsPolicy.DefaultPolicyName, ServerCorsPolicy.DefaultPolicy); options.AddPolicy(ServerCorsPolicy.DefaultPolicyName, ServerCorsPolicy.DefaultPolicy);
@ -177,6 +181,16 @@ namespace Jellyfin.Server.Extensions
options.JsonSerializerOptions.PropertyNamingPolicy = jsonOptions.PropertyNamingPolicy; options.JsonSerializerOptions.PropertyNamingPolicy = jsonOptions.PropertyNamingPolicy;
}) })
.AddControllersAsServices(); .AddControllersAsServices();
if (applicationHost.Plugins != null)
{
foreach (IPlugin plugin in applicationHost.Plugins)
{
mvcBuilder.AddApplicationPart(plugin.GetType().Assembly);
}
}
return mvcBuilder;
} }
/// <summary> /// <summary>

@ -2,8 +2,10 @@ using System.Net.Http;
using Jellyfin.Server.Extensions; using Jellyfin.Server.Extensions;
using Jellyfin.Server.Middleware; using Jellyfin.Server.Middleware;
using Jellyfin.Server.Models; using Jellyfin.Server.Models;
using MediaBrowser.Common;
using MediaBrowser.Controller; using MediaBrowser.Controller;
using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.Configuration;
using MediaBrowser.Model.Serialization;
using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Builder;
using Microsoft.AspNetCore.Hosting; using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.DependencyInjection;
@ -18,14 +20,17 @@ namespace Jellyfin.Server
public class Startup public class Startup
{ {
private readonly IServerConfigurationManager _serverConfigurationManager; private readonly IServerConfigurationManager _serverConfigurationManager;
private readonly IApplicationHost _applicationHost;
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Startup" /> class. /// Initializes a new instance of the <see cref="Startup" /> class.
/// </summary> /// </summary>
/// <param name="serverConfigurationManager">The server configuration manager.</param> /// <param name="serverConfigurationManager">The server configuration manager.</param>
public Startup(IServerConfigurationManager serverConfigurationManager) /// <param name="applicationHost">The application host.</param>
public Startup(IServerConfigurationManager serverConfigurationManager, IApplicationHost applicationHost)
{ {
_serverConfigurationManager = serverConfigurationManager; _serverConfigurationManager = serverConfigurationManager;
_applicationHost = applicationHost;
} }
/// <summary> /// <summary>
@ -36,7 +41,7 @@ namespace Jellyfin.Server
{ {
services.AddResponseCompression(); services.AddResponseCompression();
services.AddHttpContextAccessor(); services.AddHttpContextAccessor();
services.AddJellyfinApi(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/')); services.AddJellyfinApi(_serverConfigurationManager.Configuration.BaseUrl.TrimStart('/'), _applicationHost);
services.AddJellyfinApiSwagger(); services.AddJellyfinApiSwagger();

Loading…
Cancel
Save