Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add user-agent when sending HTTP request #1

Merged
merged 4 commits into from
Jul 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 7 additions & 44 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,11 @@ on:
push:

jobs:
test-nix:
name: Test on *NIX
timeout-minutes: 30
strategy:
matrix:
os:
- "ubuntu-24.04"
dotnet-version:
- "net8.0"
runs-on: ${{ matrix.os }}
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
submodules: recursive

- name: Set up .NET
uses: actions/setup-dotnet@v4
Expand All @@ -28,44 +19,16 @@ jobs:
- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
key: nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-
nuget-

- name: Install dependencies
run: |
dotnet restore

- name: Build
run: |
dotnet build -f ${{ matrix.dotnet-version }} --no-restore

test-windows:
name: Test on Windows
timeout-minutes: 30
strategy:
matrix:
dotnet-version:
- "net8.0"
runs-on: "windows-2022"
steps:
- uses: actions/checkout@v4
with:
submodules: recursive
dotnet build --no-restore

- name: Set up .NET
uses: actions/setup-dotnet@v4
with:
dotnet-version: |
8.0.x

- uses: actions/cache@v4
with:
path: ~/.nuget/packages
key: ${{ runner.os }}-nuget-${{ hashFiles('**/*.csproj') }}
restore-keys: |
${{ runner.os }}-nuget-

- name: Install dependencies
run: |
dotnet restore

2 changes: 1 addition & 1 deletion Directory.Build.props
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<Project>
<PropertyGroup>
<VersionPrefix>0.2.0-beta</VersionPrefix>
<VersionPrefix>0.2.0-charlie</VersionPrefix>
<Authors>KJB Conseil</Authors>
<PackageProjectUrl>https://github.com/kjbconseil/logtoapi-dotnet-sdk</PackageProjectUrl>
<RepositoryUrl>https://github.com/kjbconseil/logtoapi-dotnet-sdk</RepositoryUrl>
Expand Down
3 changes: 3 additions & 0 deletions src/Logto.WebApi.Sdk/Common/ApiClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Net.Http.Headers;
using System.Reflection;
using System.Text;
using System.Text.Json;
using Logto.WebApi.Sdk.Authentication;
Expand Down Expand Up @@ -65,6 +66,8 @@ protected async Task AuthenticateAsync()
}

request.Headers.Authorization = new AuthenticationHeaderValue("Bearer", _currentToken!.Value);
request.Headers.UserAgent.Add(new ProductInfoHeaderValue("logto-webapi-dotnet-sdk", Assembly.GetExecutingAssembly().GetName().Version?.ToString()));
request.Headers.UserAgent.Add(new ProductInfoHeaderValue("dotnet-version", Environment.Version.ToString()));

var response = await HttpClient.SendAsync(request);
response.EnsureSuccessStatusCode();
Expand Down