mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-12-17 06:23:03 +03:00
Merge pull request #3871 from Ullmie02/plugins-api
Allow plugins to define their own api endpoints
This commit is contained in:
@@ -18,6 +18,7 @@ using Jellyfin.Api.Constants;
|
||||
using Jellyfin.Api.Controllers;
|
||||
using Jellyfin.Server.Formatters;
|
||||
using Jellyfin.Server.Models;
|
||||
using MediaBrowser.Common;
|
||||
using MediaBrowser.Common.Json;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using Microsoft.AspNetCore.Authentication;
|
||||
@@ -135,10 +136,11 @@ namespace Jellyfin.Server.Extensions
|
||||
/// </summary>
|
||||
/// <param name="serviceCollection">The service collection.</param>
|
||||
/// <param name="baseUrl">The base url for the API.</param>
|
||||
/// <param name="pluginAssemblies">An IEnumberable containing all plugin assemblies with API controllers.</param>
|
||||
/// <returns>The MVC builder.</returns>
|
||||
public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl)
|
||||
public static IMvcBuilder AddJellyfinApi(this IServiceCollection serviceCollection, string baseUrl, IEnumerable<Assembly> pluginAssemblies)
|
||||
{
|
||||
return serviceCollection
|
||||
IMvcBuilder mvcBuilder = serviceCollection
|
||||
.AddCors(options =>
|
||||
{
|
||||
options.AddPolicy(ServerCorsPolicy.DefaultPolicyName, ServerCorsPolicy.DefaultPolicy);
|
||||
@@ -179,8 +181,14 @@ namespace Jellyfin.Server.Extensions
|
||||
|
||||
// From JsonDefaults.PascalCase
|
||||
options.JsonSerializerOptions.PropertyNamingPolicy = jsonOptions.PropertyNamingPolicy;
|
||||
})
|
||||
.AddControllersAsServices();
|
||||
});
|
||||
|
||||
foreach (Assembly pluginAssembly in pluginAssemblies)
|
||||
{
|
||||
mvcBuilder.AddApplicationPart(pluginAssembly);
|
||||
}
|
||||
|
||||
return mvcBuilder.AddControllersAsServices();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
||||
Reference in New Issue
Block a user