|
@@ -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.
|