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

52 lines
1.6 KiB
C#
Raw Normal View History

using MediaBrowser.Common.Net;
using ServiceStack.ServiceHost;
2013-03-04 20:34:02 -07:00
using System.Diagnostics;
using System.IO;
2013-03-06 22:34:00 -07:00
namespace MediaBrowser.Server.Implementations.HttpServer
2013-03-04 20:34:02 -07:00
{
/// <summary>
/// Class GetDashboardResource
/// </summary>
[Route("/swagger-ui/{ResourceName*}", "GET")]
public class GetSwaggerResource
{
/// <summary>
/// Gets or sets the name.
/// </summary>
/// <value>The name.</value>
public string ResourceName { get; set; }
}
2013-04-14 11:09:40 -07:00
public class SwaggerService : IHasResultFactory, IRestfulService
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 runningDirectory = Path.GetDirectoryName(Process.GetCurrentProcess().MainModule.FileName);
var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui");
var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', '\\'));
2013-04-14 11:09:40 -07:00
return ResultFactory.GetStaticFileResult(RequestContext, requestedFile);
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>
public IRequestContext RequestContext { get; set; }
2013-03-04 20:34:02 -07:00
}
}