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.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

TrackService.cs 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. using Grpc.Core;
  2. using GrpcShared;
  3. using GrpcShared.DTO.Search;
  4. using GrpcShared.Interfaces;
  5. using Microsoft.Net.Http.Headers;
  6. using Newtonsoft.Json;
  7. using System.Text;
  8. using System.Text.Json;
  9. namespace SpotifyService.Services
  10. {
  11. public class TrackService : ITrackService
  12. {
  13. private readonly IHttpClientFactory _httpClientFactory;
  14. public TrackService(IHttpClientFactory httpClientFactory)
  15. {
  16. _httpClientFactory = httpClientFactory;
  17. }
  18. public async Task<SearchResponse> ListSearchAsync(SearchRequest request)
  19. {
  20. var client = _httpClientFactory.CreateClient("HttpClient");
  21. client.DefaultRequestHeaders.Add(HeaderNames.Authorization, "Bearer " + request.Token );
  22. var searchResult = await client.GetAsync($"search?q={request.Query}&type={request.Type}");
  23. var responses = JsonConvert.DeserializeObject<SearchResponse>(await searchResult.Content.ReadAsStringAsync())!;
  24. return new SearchResponse
  25. {
  26. Tracks = responses!.Tracks
  27. };
  28. }
  29. }
  30. }