mirror of
https://github.com/ppy/osu.git
synced 2025-02-19 12:23:13 +08:00
Add API versioning
This commit is contained in:
parent
4889750959
commit
7f4cc221d2
@ -36,6 +36,8 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public string WebsiteRootUrl { get; }
|
public string WebsiteRootUrl { get; }
|
||||||
|
|
||||||
|
public int APIVersion => 20220217; // We may want to pull this from the game version eventually.
|
||||||
|
|
||||||
public Exception LastLoginError { get; private set; }
|
public Exception LastLoginError { get; private set; }
|
||||||
|
|
||||||
public string ProvidedUsername { get; private set; }
|
public string ProvidedUsername { get; private set; }
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
// See the LICENCE file in the repository root for full licence text.
|
// See the LICENCE file in the repository root for full licence text.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using JetBrains.Annotations;
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
using osu.Framework.IO.Network;
|
using osu.Framework.IO.Network;
|
||||||
@ -112,6 +113,9 @@ namespace osu.Game.Online.API
|
|||||||
WebRequest = CreateWebRequest();
|
WebRequest = CreateWebRequest();
|
||||||
WebRequest.Failed += Fail;
|
WebRequest.Failed += Fail;
|
||||||
WebRequest.AllowRetryOnTimeout = false;
|
WebRequest.AllowRetryOnTimeout = false;
|
||||||
|
|
||||||
|
WebRequest.AddHeader("x-api-version", API.APIVersion.ToString(CultureInfo.InvariantCulture));
|
||||||
|
|
||||||
if (!string.IsNullOrEmpty(API.AccessToken))
|
if (!string.IsNullOrEmpty(API.AccessToken))
|
||||||
WebRequest.AddHeader("Authorization", $"Bearer {API.AccessToken}");
|
WebRequest.AddHeader("Authorization", $"Bearer {API.AccessToken}");
|
||||||
|
|
||||||
|
@ -33,6 +33,8 @@ namespace osu.Game.Online.API
|
|||||||
|
|
||||||
public string WebsiteRootUrl => "http://localhost";
|
public string WebsiteRootUrl => "http://localhost";
|
||||||
|
|
||||||
|
public int APIVersion => int.Parse(DateTime.Now.ToString("yyyyMMdd"));
|
||||||
|
|
||||||
public Exception LastLoginError { get; private set; }
|
public Exception LastLoginError { get; private set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -57,6 +57,11 @@ namespace osu.Game.Online.API
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
string WebsiteRootUrl { get; }
|
string WebsiteRootUrl { get; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The version of the API.
|
||||||
|
/// </summary>
|
||||||
|
int APIVersion { get; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The last login error that occurred, if any.
|
/// The last login error that occurred, if any.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
Loading…
Reference in New Issue
Block a user