2using System.Collections.Generic;
3using System.Linq.Expressions;
5using Microsoft.AspNetCore.Authorization;
6using Microsoft.AspNetCore.Hosting;
7using Microsoft.AspNetCore.Mvc;
8using Microsoft.Extensions.Logging;
9using Microsoft.Extensions.Options;
23 [ApiExplorerSettings(IgnoreApi =
true)]
69 readonly ILogger<RootController>
logger;
78 var memberSelectorExpression = (MethodCallExpression)actionExpression.Body;
79 var method = memberSelectorExpression.Method;
83 const string ControllerSuffix = nameof(
Controller);
84 if (controllerName.EndsWith(ControllerSuffix, StringComparison.Ordinal))
85 controllerName = controllerName.Substring(0, controllerName.Length - ControllerSuffix.Length);
87 var actionName = method.Name;
89 return Tuple.Create<string,
string?>(controllerName, actionName);
106 ILogger<RootController>
logger,
114 this.logger =
logger ??
throw new ArgumentNullException(nameof(
logger));
131 var controlPanelRoute = $
"{ControlPanelController.ControlPanelRoute.TrimStart('/')}/";
132 if (panelEnabled && !apiDocsEnabled)
133 return Redirect(controlPanelRoute);
135 Dictionary<string, string>? links =
null;
137 if (panelEnabled || apiDocsEnabled)
139 links =
new Dictionary<string, string>();
142 links.Add(
"Web Control Panel", controlPanelRoute);
168 [HttpGet(
"logo.svg")]
181 return (IActionResult?)this.TryServeFile(
hostEnvironment,
logger, $
"{LogoSvgLinuxName}.svg") ?? NotFound();
193 return RedirectToActionPermanent(
Routes to a server actions.
const string GraphQL
The GraphQL route.
Controller for the web control panel.
const string ChannelJsonRoute
The route to the control panel channel .json.
The root path Controller.
const string LogoSvgWindowsName
The name of the TGS logo .svg in the IWebHostEnvironment.WebRootPath on Windows.
readonly IOptions< ControlPanelConfiguration > controlPanelConfigurationOptions
The IOptions<TOptions> of ControlPanelConfiguration for the RootController.
readonly IPlatformIdentifier platformIdentifier
The IPlatformIdentifier for the RootController.
readonly ILogger< RootController > logger
The ILogger for the RootController.
RedirectToActionResult WebpanelChannelRedirect()
Workaround for the webpanel always expecting a trailing slash.
IActionResult Index()
Gets the server's homepage.
readonly IAssemblyInformationProvider assemblyInformationProvider
The IAssemblyInformationProvider for the RootController.
RootController(IAssemblyInformationProvider assemblyInformationProvider, IPlatformIdentifier platformIdentifier, IWebHostEnvironment hostEnvironment, ILogger< RootController > logger, IOptions< GeneralConfiguration > generalConfigurationOptions, IOptions< ControlPanelConfiguration > controlPanelConfigurationOptions, IOptions< InternalConfiguration > internalConfigurationOptions)
Initializes a new instance of the RootController class.
const string LogoSvgLinuxName
The name of the TGS logo .svg in the IWebHostEnvironment.WebRootPath on Linux.
readonly IOptions< InternalConfiguration > internalConfigurationOptions
The IOptions<TOptions> of InternalConfiguration for the RootController.
readonly IOptions< GeneralConfiguration > generalConfigurationOptions
The IOptions<TOptions> of GeneralConfiguration for the RootController.
readonly IWebHostEnvironment hostEnvironment
THe IWebHostEnvironment for the RootController.
static Tuple< string, string?> GetControlPanelActionLink(Expression< Func< ControlPanelController, IActionResult > > actionExpression)
Gets a Tuple<T1, T2> giving the ControlPanelController and action names for a given actionExpression ...
IActionResult GetLogo()
Retrieve the logo .svg for the webpanel.
Implements various filters for Swashbuckle.
const string DocumentationSiteRouteExtension
The path to the hosted documentation site.