Skip to content

Commit

Permalink
[Kafka.DotNet.ksqlDB] - HttpResponseMessageExtensions.ToStatementResp…
Browse files Browse the repository at this point in the history
…onses
  • Loading branch information
tomasfabian committed Apr 18, 2021
1 parent 8545b7c commit ef7c178
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
using System.Net.Http;
using System.Text.Json;
using Kafka.DotNet.ksqlDB.KSql.RestApi.Statements;

namespace Kafka.DotNet.ksqlDB.KSql.RestApi.Extensions
{
public static class HttpResponseMessageExtensions
{
public static StatementResponse[] ToStatementResponses(this HttpResponseMessage httpResponseMessage)
{
string responseContent = httpResponseMessage.Content.ReadAsStringAsync().Result;

var responseObjects = JsonSerializer.Deserialize<StatementResponse[]>(responseContent);

return responseObjects;
}

public static StatementResponse ToStatementResponse(this HttpResponseMessage httpResponseMessage)
{
string responseContent = httpResponseMessage.Content.ReadAsStringAsync().Result;

var responseObject = JsonSerializer.Deserialize<StatementResponse>(responseContent);

return responseObject;
}
}
}
4 changes: 3 additions & 1 deletion Joker.Kafka/KSql/RestApi/Statements/StatementResponse.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
using System.Text.Json.Serialization;
using System;
using System.Net;
using System.Text.Json.Serialization;

namespace Kafka.DotNet.ksqlDB.KSql.RestApi.Statements
{
Expand Down

0 comments on commit ef7c178

Please sign in to comment.