jellyfin/MediaBrowser.Server.Implementations/HttpServer/SwaggerService.cs

44 lines
1.4 KiB
C#
Raw Normal View History

using MediaBrowser.Controller;
2013-12-07 08:52:38 -07:00
using MediaBrowser.Controller.Net;
using ServiceStack.Web;
2013-03-04 20:34:02 -07:00
using System.IO;
2013-03-06 22:34:00 -07:00
namespace MediaBrowser.Server.Implementations.HttpServer
2013-03-04 20:34:02 -07:00
{
2013-04-14 11:09:40 -07:00
public class SwaggerService : IHasResultFactory, IRestfulService
2013-03-04 20:34:02 -07:00
{
private readonly IServerApplicationPaths _appPaths;
public SwaggerService(IServerApplicationPaths appPaths)
{
_appPaths = appPaths;
}
2013-03-04 20:34:02 -07:00
/// <summary>
/// Gets the specified request.
/// </summary>
/// <param name="request">The request.</param>
/// <returns>System.Object.</returns>
public object Get(GetSwaggerResource request)
{
var swaggerDirectory = Path.Combine(_appPaths.ApplicationResourcesPath, "swagger-ui");
2013-03-04 20:34:02 -07:00
var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', Path.DirectorySeparatorChar));
2013-03-04 20:34:02 -07:00
2016-06-18 23:18:29 -07:00
return ResultFactory.GetStaticFileResult(Request, requestedFile).Result;
2013-03-04 20:34:02 -07:00
}
2013-04-14 11:09:40 -07:00
/// <summary>
/// Gets or sets the result factory.
/// </summary>
/// <value>The result factory.</value>
public IHttpResultFactory ResultFactory { get; set; }
/// <summary>
/// Gets or sets the request context.
/// </summary>
/// <value>The request context.</value>
2013-12-07 08:52:38 -07:00
public IRequest Request { get; set; }
2013-03-04 20:34:02 -07:00
}
}