1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859 |
- using MediaBrowser.Common.Configuration;
- using MediaBrowser.Controller.Net;
- using ServiceStack;
- using ServiceStack.Web;
- using System.IO;
- namespace MediaBrowser.Server.Implementations.HttpServer
- {
- /// <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 : IHasResultFactory, IRestfulService
- {
- private readonly IApplicationPaths _appPaths;
- public SwaggerService(IApplicationPaths appPaths)
- {
- _appPaths = appPaths;
- }
- /// <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(_appPaths.ApplicationPath);
- var swaggerDirectory = Path.Combine(runningDirectory, "swagger-ui");
- var requestedFile = Path.Combine(swaggerDirectory, request.ResourceName.Replace('/', Path.DirectorySeparatorChar));
- return ResultFactory.GetStaticFileResult(Request, requestedFile);
- }
- /// <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 IRequest Request { get; set; }
- }
- }
|