Blazor & WASM in combination to get statistics from Spotify API for performing the song analysis. With separate microservices for auth, Spotify, user data tracking, and application, connected through gRPC with Polly.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

HttpUtils.cs 937B

12345678910111213141516171819202122232425262728293031323334
  1. using Grpc.Net.Client;
  2. using Microsoft.Net.Http.Headers;
  3. using Newtonsoft.Json;
  4. namespace SpotifyService.HttpUtils
  5. {
  6. public static class HttpUtils<T>
  7. {
  8. public static async Task<T> GetData(HttpClient client, string url, string token)
  9. {
  10. //add header
  11. client.DefaultRequestHeaders.Add(HeaderNames.Authorization, "Bearer " + token);
  12. //get request
  13. var req = await client.GetAsync(url);
  14. //read response
  15. var response = JsonConvert.DeserializeObject<T>(await req.Content.ReadAsStringAsync())!;
  16. return response;
  17. }
  18. public static async Task PutData(HttpClient client, string url, string token)
  19. {
  20. //add header
  21. client.DefaultRequestHeaders.Add(HeaderNames.Authorization, "Bearer " + token);
  22. //get request
  23. await client.PutAsync(url, null);
  24. }
  25. }
  26. }