mirror of
https://github.com/DorkSquadRR/DorkNet.git
synced 2026-10-25 23:18:44 -07:00
4edf25b2d5
Targets Rec Room 2020.12.18 client.
Re-import after adding:
- DorkNet.ClientMod/dorknet-clientmod.json.template — config schema
the launcher's manifest-driven patcher renders into UserData/.
- tools/build-patcher-zip.ps1 — produces the dorknet-clientpatch-{key}.zip
Release asset the launcher fetches.
- .github/workflows/release.yml — auto-publishes both Release assets
on v1-december-* tag push.
Scrubbed via maintainer-side scrub-for-public.ps1: same drop rules as
the prior import, plus build-patcher-zip.ps1 added to the tools/
allow-list so it survives the scrub.
30 lines
1.3 KiB
C#
30 lines
1.3 KiB
C#
using Microsoft.AspNetCore.Http;
|
|
|
|
namespace DorkNet.Server.Compat;
|
|
|
|
/// <summary>Helpers to read the active <see cref="ClientVersion"/>
|
|
/// off the current request. The version is set by
|
|
/// <c>VersionDetectionMiddleware</c> early in the pipeline so any
|
|
/// downstream consumer (controllers, services, filters) can resolve
|
|
/// it without re-parsing the header.</summary>
|
|
public static class HttpContextExtensions
|
|
{
|
|
private const string ClientVersionKey = "DorkNet.ClientVersion";
|
|
|
|
/// <summary>Stamp the resolved version on the request. Called by
|
|
/// <c>VersionDetectionMiddleware</c>; not for general use.</summary>
|
|
internal static void SetClientVersion(this HttpContext ctx, ClientVersion v)
|
|
=> ctx.Items[ClientVersionKey] = v;
|
|
|
|
/// <summary>The client version for this request. Returns
|
|
/// <see cref="ClientVersion.Unknown"/> if the middleware hasn't
|
|
/// run (e.g. a unit test that calls a controller method directly)
|
|
/// rather than null, so callers can safely branch on
|
|
/// <c>Generation</c> without null-checks.</summary>
|
|
public static ClientVersion ClientVersion(this HttpContext ctx)
|
|
=> ctx.Items.TryGetValue(ClientVersionKey, out var v)
|
|
&& v is ClientVersion cv
|
|
? cv
|
|
: Compat.ClientVersion.Unknown;
|
|
}
|