aboutsummaryrefslogtreecommitdiff
path: root/MediaBrowser.Common.Implementations/HttpServer/SwaggerService.cs
blob: a4808834dfcba10e04d2bf7c65fb220197e9e1eb (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
using ServiceStack.ServiceHost;
using System.Diagnostics;
using System.IO;

namespace MediaBrowser.Common.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 : 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);
        }
    }
}