feat: 初始功能

This commit is contained in:
Shiqvlizi Name
2026-05-23 18:16:50 +08:00
parent a5bfd8792e
commit 9a51259e9e
63 changed files with 5377 additions and 1 deletions

View File

@@ -0,0 +1,30 @@
using CloudPrint.Client.Models;
using Grpc.Core;
namespace CloudPrint.Client.Services.Grpc;
public static class GrpcMetadataFactory
{
public static Metadata Create(string apiKey, string printerToken, AdminSession adminSession)
{
var metadata = new Metadata();
AddIfNotEmpty(metadata, "x-api-key", apiKey);
AddIfNotEmpty(metadata, "x-printer-token", printerToken);
if (adminSession.IsAuthenticated)
{
metadata.Add("authorization", $"Bearer {adminSession.AccessToken}");
}
return metadata;
}
private static void AddIfNotEmpty(Metadata metadata, string key, string value)
{
if (!string.IsNullOrWhiteSpace(value))
{
metadata.Add(key, value);
}
}
}