mirror of
https://github.com/tgstation/tgstation-server.git
synced 2026-08-22 20:47:28 +01:00
Merge pull request #1776 from tgstation/1761-FixProxyShit [TGSDeploy]
v6.1.4: Fix more subpath stupidity
This commit is contained in:
+1
-1
@@ -3,7 +3,7 @@
|
||||
<!-- Integration tests will ensure they match across the board -->
|
||||
<Import Project="WebpanelVersion.props" />
|
||||
<PropertyGroup>
|
||||
<TgsCoreVersion>6.1.3</TgsCoreVersion>
|
||||
<TgsCoreVersion>6.1.4</TgsCoreVersion>
|
||||
<TgsConfigVersion>5.0.0</TgsConfigVersion>
|
||||
<TgsApiVersion>10.0.0</TgsApiVersion>
|
||||
<TgsCommonLibraryVersion>7.0.0</TgsCommonLibraryVersion>
|
||||
|
||||
@@ -22,9 +22,6 @@ Installers:
|
||||
AppsAndFeaturesEntries:
|
||||
- DisplayName: tgstation-server
|
||||
Publisher: /tg/station 13
|
||||
Dependencies:
|
||||
PackageDependencies:
|
||||
- PackageIdentifier: Microsoft.DotNet.HostingBundle.8
|
||||
ReleaseDate: 2023-06-24 # Do not change. Set before publish by push_manifest.ps1
|
||||
ManifestType: installer
|
||||
ManifestVersion: 1.5.0
|
||||
|
||||
@@ -30,6 +30,11 @@ namespace Tgstation.Server.Host.Controllers
|
||||
/// </summary>
|
||||
public const string ControlPanelRoute = "/app";
|
||||
|
||||
/// <summary>
|
||||
/// The route to the control panel channel .json.
|
||||
/// </summary>
|
||||
public const string ChannelJsonRoute = "channel.json";
|
||||
|
||||
/// <summary>
|
||||
/// Header for forcing channel.json to be fetched.
|
||||
/// </summary>
|
||||
@@ -70,7 +75,7 @@ namespace Tgstation.Server.Host.Controllers
|
||||
/// Returns the <see cref="ControlPanelConfiguration.Channel"/>.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="JsonResult"/> with the <see cref="ControlPanelConfiguration.Channel"/>.</returns>
|
||||
[Route("channel.json")]
|
||||
[Route(ChannelJsonRoute)]
|
||||
[HttpGet]
|
||||
public IActionResult GetChannelJson()
|
||||
{
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq.Expressions;
|
||||
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Hosting;
|
||||
@@ -61,6 +62,27 @@ namespace Tgstation.Server.Host.Controllers
|
||||
/// </summary>
|
||||
readonly ControlPanelConfiguration controlPanelConfiguration;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a <see cref="Tuple{T1, T2}"/> giving the <see cref="ControlPanelController"/> and action names for a given <paramref name="actionExpression"/>.
|
||||
/// </summary>
|
||||
/// <param name="actionExpression">An expression invoking the action on <see cref="ControlPanelController"/>.</param>
|
||||
/// <returns>A <see cref="Tuple{T1, T2}"/> containing the controller and action names.</returns>
|
||||
static Tuple<string, string?> GetControlPanelActionLink(Expression<Func<ControlPanelController, IActionResult>> actionExpression)
|
||||
{
|
||||
var memberSelectorExpression = (MethodCallExpression)actionExpression.Body;
|
||||
var method = memberSelectorExpression.Method;
|
||||
|
||||
var controllerName = typeof(ControlPanelController).Name;
|
||||
|
||||
const string ControllerSuffix = nameof(Controller);
|
||||
if (controllerName.EndsWith(ControllerSuffix, StringComparison.Ordinal))
|
||||
controllerName = controllerName.Substring(0, controllerName.Length - ControllerSuffix.Length);
|
||||
|
||||
var actionName = method.Name;
|
||||
|
||||
return Tuple.Create<string, string?>(controllerName, actionName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RootController"/> class.
|
||||
/// </summary>
|
||||
@@ -136,5 +158,19 @@ namespace Tgstation.Server.Host.Controllers
|
||||
|
||||
return (IActionResult?)this.TryServeFile(hostEnvironment, logger, $"{logoFileName}.svg") ?? NotFound();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Workaround for the webpanel always expecting a trailing slash.
|
||||
/// </summary>
|
||||
/// <returns>A <see cref="RedirectResult"/> to the <see cref="ControlPanelController.GetChannelJson"/>.</returns>
|
||||
[HttpGet(ControlPanelController.ChannelJsonRoute)]
|
||||
public RedirectToActionResult WebpanelChannelRedirect()
|
||||
{
|
||||
var actionTuple = GetControlPanelActionLink(controller => controller.GetChannelJson());
|
||||
|
||||
return RedirectToActionPermanent(
|
||||
actionTuple.Item2,
|
||||
actionTuple.Item1);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -503,6 +503,10 @@ namespace Tgstation.Server.Host.Core
|
||||
|
||||
if (generalConfiguration.HostApiDocumentation)
|
||||
{
|
||||
var siteDocPath = Routes.ApiRoot + $"doc/{SwaggerConfiguration.DocumentName}.json";
|
||||
if (!String.IsNullOrWhiteSpace(controlPanelConfiguration.PublicPath))
|
||||
siteDocPath = controlPanelConfiguration.PublicPath.TrimEnd('/') + siteDocPath;
|
||||
|
||||
applicationBuilder.UseSwagger(options =>
|
||||
{
|
||||
options.RouteTemplate = Routes.ApiRoot + "doc/{documentName}.{json|yaml}";
|
||||
@@ -510,7 +514,7 @@ namespace Tgstation.Server.Host.Core
|
||||
applicationBuilder.UseSwaggerUI(options =>
|
||||
{
|
||||
options.RoutePrefix = SwaggerConfiguration.DocumentationSiteRouteExtension;
|
||||
options.SwaggerEndpoint(Routes.ApiRoot + $"doc/{SwaggerConfiguration.DocumentName}.json", "TGS API");
|
||||
options.SwaggerEndpoint(siteDocPath, "TGS API");
|
||||
});
|
||||
logger.LogTrace("Swagger API generation enabled");
|
||||
}
|
||||
@@ -524,6 +528,7 @@ namespace Tgstation.Server.Host.Core
|
||||
RequestPath = ControlPanelController.ControlPanelRoute,
|
||||
EnableDefaultFiles = true,
|
||||
EnableDirectoryBrowsing = false,
|
||||
RedirectToAppendTrailingSlash = false,
|
||||
});
|
||||
}
|
||||
else
|
||||
|
||||
Reference in New Issue
Block a user