Vortac
How to use Server Sent Events with HttpClient
I'm working with an API framework (https://docs.mistral.ai/api/#operation/createChatCompletion) in which you send a chat request. If you set the stream parameter to true:
To handle this, I created an SssEvent class with the following properties:
I have the code working for non-streaming calls, but I'm confused as to how to send my initial message and then stream back the response. My code currently looks like this:
https://paste.mozilla.org/BD3gMX5o
6 replies
Interface Design Question
I have an interface IAuthenticatable with one method:
Task<Tokens> GetAccessTokensAsync()
that I'd like to use for two different API authentication classes. However, the two authenticated API responses vary, so I'm just wondering what I should do. Use separete interfaces for each API?14 replies
✅ Streaming From REST API?
I'm building an SDK to interface with a REST API, and for one of then endpoints you can supply a boolean to specify if you want streaming or not. In particular, it mentions:
I'm just wondering, do I use HTTPClient for this? Or is there another way to handle streams?
15 replies
ASP .NET 7 - Testing a JWT Token Generator
I have an ASP .NET web api which calls a CreateToken() method inside a TokenService to generate a JWT when a user logs in. The public implementation looks like this:
There's also 3 private helper methods inside TokenService which are used to help generate the token. I should only be testing the public method correct? Also, what should I be testing for here? I've done basic unit tests before (like testing an AddNumbers(int 1, int 2)), but am I supposed to generate the token in the test and then compare it to a "correctly" generated version?
1 replies