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

39 lines
1.1 KiB
C#
Raw Normal View History

2013-03-05 03:34:02 +00:00
using ServiceStack.ServiceHost;
using System.Diagnostics;
using System.IO;
2013-03-07 05:34:00 +00:00
namespace MediaBrowser.Server.Implementations.HttpServer
2013-03-05 03:34:02 +00: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; }
}
public class SwaggerService : BaseRestService
{
/// <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('/', '\\'));
return ToStaticFileResult(requestedFile);
}
}
}