mirror of
https://github.com/jellyfin/jellyfin.git
synced 2026-03-20 17:16:42 +00:00
support api without /mediabrowser
This commit is contained in:
@@ -1,5 +1,4 @@
|
||||
using MediaBrowser.Common.Configuration;
|
||||
using MediaBrowser.Common.Extensions;
|
||||
using MediaBrowser.Common.Net;
|
||||
using MediaBrowser.Controller;
|
||||
using MediaBrowser.Controller.Configuration;
|
||||
|
||||
@@ -24,7 +24,6 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
{
|
||||
public class HttpListenerHost : ServiceStackHost, IHttpServer
|
||||
{
|
||||
private string HandlerPath { get; set; }
|
||||
private string DefaultRedirectPath { get; set; }
|
||||
|
||||
private readonly ILogger _logger;
|
||||
@@ -64,18 +63,16 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
}
|
||||
}
|
||||
|
||||
public HttpListenerHost(IApplicationHost applicationHost,
|
||||
ILogManager logManager,
|
||||
string serviceName,
|
||||
string handlerPath,
|
||||
string defaultRedirectPath,
|
||||
bool supportsNativeWebSocket,
|
||||
public HttpListenerHost(IApplicationHost applicationHost,
|
||||
ILogManager logManager,
|
||||
string serviceName,
|
||||
string defaultRedirectPath,
|
||||
bool supportsNativeWebSocket,
|
||||
params Assembly[] assembliesWithServices)
|
||||
: base(serviceName, assembliesWithServices)
|
||||
{
|
||||
DefaultRedirectPath = defaultRedirectPath;
|
||||
_supportsNativeWebSocket = supportsNativeWebSocket;
|
||||
HandlerPath = handlerPath;
|
||||
|
||||
_logger = logManager.GetLogger("HttpServer");
|
||||
|
||||
@@ -136,13 +133,9 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
{
|
||||
base.OnConfigLoad();
|
||||
|
||||
Config.HandlerFactoryPath = string.IsNullOrEmpty(HandlerPath)
|
||||
? null
|
||||
: HandlerPath;
|
||||
Config.HandlerFactoryPath = null;
|
||||
|
||||
Config.MetadataRedirectPath = string.IsNullOrEmpty(HandlerPath)
|
||||
? "metadata"
|
||||
: PathUtils.CombinePaths(HandlerPath, "metadata");
|
||||
Config.MetadataRedirectPath = "metadata";
|
||||
}
|
||||
|
||||
protected override ServiceController CreateServiceController(params Assembly[] assembliesWithServices)
|
||||
@@ -245,7 +238,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
var errorResponse = new ErrorResponse
|
||||
{
|
||||
ResponseStatus = new ResponseStatus
|
||||
@@ -314,24 +307,24 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
var operationName = httpReq.OperationName;
|
||||
var localPath = url.LocalPath;
|
||||
|
||||
if (string.Equals(localPath, "/" + HandlerPath + "/", StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(localPath, "/mediabrowser/", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
httpRes.RedirectToUrl(DefaultRedirectPath);
|
||||
httpRes.RedirectToUrl("/../" + DefaultRedirectPath);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
if (string.Equals(localPath, "/" + HandlerPath, StringComparison.OrdinalIgnoreCase))
|
||||
if (string.Equals(localPath, "/mediabrowser", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
httpRes.RedirectToUrl(HandlerPath + "/" + DefaultRedirectPath);
|
||||
httpRes.RedirectToUrl("../" + DefaultRedirectPath);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
if (string.Equals(localPath, "/", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
httpRes.RedirectToUrl(HandlerPath + "/" + DefaultRedirectPath);
|
||||
httpRes.RedirectToUrl(DefaultRedirectPath);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
if (string.IsNullOrEmpty(localPath))
|
||||
{
|
||||
httpRes.RedirectToUrl("/" + HandlerPath + "/" + DefaultRedirectPath);
|
||||
httpRes.RedirectToUrl("/" + DefaultRedirectPath);
|
||||
return Task.FromResult(true);
|
||||
}
|
||||
|
||||
@@ -386,12 +379,33 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
base.Init();
|
||||
}
|
||||
|
||||
//public override RouteAttribute[] GetRouteAttributes(System.Type requestType)
|
||||
//{
|
||||
// var routes = base.GetRouteAttributes(requestType);
|
||||
// routes.Each(x => x.Path = "/api" + x.Path);
|
||||
// return routes;
|
||||
//}
|
||||
public override RouteAttribute[] GetRouteAttributes(Type requestType)
|
||||
{
|
||||
var routes = base.GetRouteAttributes(requestType).ToList();
|
||||
var clone = routes.ToList();
|
||||
|
||||
foreach (var route in clone)
|
||||
{
|
||||
routes.Add(new RouteAttribute(NormalizeRoutePath(route.Path), route.Verbs)
|
||||
{
|
||||
Notes = route.Notes,
|
||||
Priority = route.Priority,
|
||||
Summary = route.Summary
|
||||
});
|
||||
}
|
||||
|
||||
return routes.ToArray();
|
||||
}
|
||||
|
||||
private string NormalizeRoutePath(string path)
|
||||
{
|
||||
if (path.StartsWith("/", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
return "/mediabrowser" + path;
|
||||
}
|
||||
|
||||
return "mediabrowser/" + path;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Releases the specified instance.
|
||||
|
||||
@@ -16,20 +16,18 @@ namespace MediaBrowser.Server.Implementations.HttpServer
|
||||
/// <param name="applicationHost">The application host.</param>
|
||||
/// <param name="logManager">The log manager.</param>
|
||||
/// <param name="serverName">Name of the server.</param>
|
||||
/// <param name="handlerPath">The handler path.</param>
|
||||
/// <param name="defaultRedirectpath">The default redirectpath.</param>
|
||||
/// <param name="supportsNativeWebSocket">if set to <c>true</c> [supports native web socket].</param>
|
||||
/// <returns>IHttpServer.</returns>
|
||||
public static IHttpServer CreateServer(IApplicationHost applicationHost,
|
||||
ILogManager logManager,
|
||||
string serverName,
|
||||
string handlerPath,
|
||||
string defaultRedirectpath,
|
||||
bool supportsNativeWebSocket)
|
||||
{
|
||||
LogManager.LogFactory = new ServerLogFactory(logManager);
|
||||
|
||||
return new HttpListenerHost(applicationHost, logManager, serverName, handlerPath, defaultRedirectpath, supportsNativeWebSocket);
|
||||
return new HttpListenerHost(applicationHost, logManager, serverName, defaultRedirectpath, supportsNativeWebSocket);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -744,7 +744,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||
|
||||
text.AppendLine("Use your web browser to visit:");
|
||||
text.AppendLine(string.Empty);
|
||||
text.AppendLine(localAddress + "/mediabrowser/web/forgotpasswordpin.html");
|
||||
text.AppendLine(localAddress + "/web/forgotpasswordpin.html");
|
||||
text.AppendLine(string.Empty);
|
||||
text.AppendLine("Enter the following pin code:");
|
||||
text.AppendLine(string.Empty);
|
||||
|
||||
@@ -46,6 +46,7 @@
|
||||
"HeaderTV": "TV",
|
||||
"HeaderAudio": "Audio",
|
||||
"HeaderVideo": "Video",
|
||||
"HeaderPaths": "Paths",
|
||||
"OptionDetectArchiveFilesAsMedia": "Detect archive files as media",
|
||||
"OptionDetectArchiveFilesAsMediaHelp": "If enabled, files with .rar and .zip extensions will be detected as media files.",
|
||||
"LabelEnterConnectUserName": "User name or email:",
|
||||
@@ -321,8 +322,8 @@
|
||||
"LabelAutomaticUpdatesFanartHelp": "If enabled, new images will be downloaded automatically as they're added to fanart.tv. Existing images will not be replaced.",
|
||||
"LabelAutomaticUpdatesTmdbHelp": "If enabled, new images will be downloaded automatically as they're added to TheMovieDB.org. Existing images will not be replaced.",
|
||||
"LabelAutomaticUpdatesTvdbHelp": "If enabled, new images will be downloaded automatically as they're added to TheTVDB.com. Existing images will not be replaced.",
|
||||
"LabelFanartApiKey": "Personal api key:",
|
||||
"LabelFanartApiKeyHelp": "Requests to fanart without a personal API key return results that were approved over 7 days ago. With a personal API key that drops to 48 hours and if you are also a fanart VIP member that will further drop to around 10 minutes.",
|
||||
"LabelFanartApiKey": "Personal api key:",
|
||||
"LabelFanartApiKeyHelp": "Requests to fanart without a personal API key return results that were approved over 7 days ago. With a personal API key that drops to 48 hours and if you are also a fanart VIP member that will further drop to around 10 minutes.",
|
||||
"ExtractChapterImagesHelp": "Extracting chapter images will allow clients to display graphical scene selection menus. The process can be slow, cpu-intensive and may require several gigabytes of space. It runs when videos are discovered, and also as a nightly scheduled task at 4am. The schedule is configurable in the scheduled tasks area. It is not recommended to run this task during peak usage hours.",
|
||||
"LabelMetadataDownloadLanguage": "Preferred download language:",
|
||||
"ButtonAutoScroll": "Auto-scroll",
|
||||
@@ -492,6 +493,7 @@
|
||||
"HeaderSystemPaths": "System Paths",
|
||||
"LinkCommunity": "Community",
|
||||
"LinkGithub": "Github",
|
||||
"LinkApi": "Api",
|
||||
"LinkApiDocumentation": "Api Documentation",
|
||||
"LabelFriendlyServerName": "Friendly server name:",
|
||||
"LabelFriendlyServerNameHelp": "This name will be used to identify this server. If left blank, the computer name will be used.",
|
||||
@@ -511,7 +513,7 @@
|
||||
|
||||
"LabelUseHttps": "Enable SSL",
|
||||
"LabelUseHttpsHelp": "Check to enable SSL hosting.",
|
||||
"LabelHttpsPort": "Local http port:",
|
||||
"LabelHttpsPort": "Local http port:",
|
||||
"LabelHttpsPortHelp": "The tcp port number that Media Browser's https server should bind to.",
|
||||
"LabelCertificatePath": "SSL Certificate path:",
|
||||
"LabelCertificatePathHelp": "The path on the filesystem to the ssl certificate pfx file.",
|
||||
|
||||
Reference in New Issue
Block a user