add ApplicationPath to app paths interface to hide implementation

This commit is contained in:
Luke Pulverenti
2013-12-04 09:52:38 -05:00
parent 40959a816f
commit 4e79eaf65e
13 changed files with 110 additions and 38 deletions

View File

@@ -99,6 +99,14 @@ namespace MediaBrowser.Server.Implementations.HttpServer
return result;
}
private bool SupportsCompression
{
get
{
return true;
}
}
/// <summary>
/// Gets the optimized result.
/// </summary>
@@ -116,7 +124,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
throw new ArgumentNullException("result");
}
var optimizedResult = requestContext.ToOptimizedResult(result);
var optimizedResult = SupportsCompression ? requestContext.ToOptimizedResult(result) : result;
if (responseHeaders != null)
{
@@ -458,6 +466,11 @@ namespace MediaBrowser.Server.Implementations.HttpServer
}
}
if (!SupportsCompression)
{
return new HttpResult(content, contentType);
}
var contents = content.Compress(requestContext.CompressionType);
return new CompressedResult(contents, requestContext.CompressionType, contentType);

View File

@@ -1,6 +1,6 @@
using MediaBrowser.Common.Net;
using MediaBrowser.Common.Configuration;
using MediaBrowser.Common.Net;
using ServiceStack.ServiceHost;
using System.Diagnostics;
using System.IO;
namespace MediaBrowser.Server.Implementations.HttpServer
@@ -20,6 +20,13 @@ namespace MediaBrowser.Server.Implementations.HttpServer
public class SwaggerService : IHasResultFactory, IRestfulService
{
private readonly IApplicationPaths _appPaths;
public SwaggerService(IApplicationPaths appPaths)
{
_appPaths = appPaths;
}
/// <summary>
/// Gets the specified request.
/// </summary>
@@ -27,7 +34,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer
/// <returns>System.Object.</returns>
public object Get(GetSwaggerResource request)
{
var runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
var runningDirectory = Path.GetDirectoryName(_appPaths.ApplicationPath);
var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui");