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.
Nelze vybrat více než 25 témat Téma musí začínat písmenem nebo číslem, může obsahovat pomlčky („-“) a může být dlouhé až 35 znaků.

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. }