Skip to content
This repository was archived by the owner on Dec 23, 2023. It is now read-only.

Commit 2a6ad25

Browse files
Added the client library version number to the HTTP headers, to help debugging problems.
1 parent d00acb5 commit 2a6ad25

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

Structurizr.Client/Api/StructurizrClient.cs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,15 @@
44
using System.IO;
55
using System.Net;
66
using System.Net.Http;
7+
using System.Reflection;
78
using System.Text;
89

910
namespace Structurizr.Api
1011
{
1112
public class StructurizrClient
1213
{
14+
15+
private string _version;
1316
private const string WorkspacePath = "/workspace/";
1417

1518
private string _url;
@@ -86,6 +89,8 @@ public StructurizrClient(string apiUrl, string apiKey, string apiSecret)
8689

8790
WorkspaceArchiveLocation = new DirectoryInfo(".");
8891
MergeFromRemote = true;
92+
93+
_version = typeof(StructurizrClient).GetTypeInfo().Assembly.GetCustomAttribute<AssemblyInformationalVersionAttribute>().InformationalVersion;
8994
}
9095

9196
public Workspace GetWorkspace(long workspaceId)
@@ -208,7 +213,7 @@ private void AddHeaders(HttpClient httpClient, string httpMethod, string path, s
208213
string authorizationHeader = new HmacAuthorizationHeader(ApiKey, hmac.Generate(hmacContent.ToString())).ToString();
209214

210215
httpClient.DefaultRequestHeaders.Add(HttpHeaders.XAuthorization, authorizationHeader);
211-
httpClient.DefaultRequestHeaders.Add(HttpHeaders.UserAgent, "structurizr-dotnet");
216+
httpClient.DefaultRequestHeaders.Add(HttpHeaders.UserAgent, "structurizr-dotnet/" + _version);
212217
httpClient.DefaultRequestHeaders.Add(HttpHeaders.Nonce, nonce);
213218
}
214219

0 commit comments

Comments
 (0)