using MediaBrowser.Controller;
using MediaBrowser.Controller.Net;
using System.IO;
using MediaBrowser.Model.IO;
using MediaBrowser.Model.Services;
namespace Emby.Server.Implementations.HttpServer
{
public class SwaggerService : IHasResultFactory, IService
{
private readonly IServerApplicationPaths _appPaths;
private readonly IFileSystem _fileSystem;
public SwaggerService(IServerApplicationPaths appPaths, IFileSystem fileSystem)
{
_appPaths = appPaths;
_fileSystem = fileSystem;
}
///
/// Gets the specified request.
///
/// The request.
/// System.Object.
public object Get(GetSwaggerResource request)
{
var swaggerDirectory = Path.Combine(_appPaths.ApplicationResourcesPath, "swagger-ui");
var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', _fileSystem.DirectorySeparatorChar));
return ResultFactory.GetStaticFileResult(Request, requestedFile).Result;
}
///
/// Gets or sets the result factory.
///
/// The result factory.
public IHttpResultFactory ResultFactory { get; set; }
///
/// Gets or sets the request context.
///
/// The request context.
public IRequest Request { get; set; }
}
}