in src/Microsoft.Azure.WebJobs.Extensions.Dapr/Triggers/DaprTriggerBindingBase.cs [196:223]
public async Task SetValueAsync(object? value, CancellationToken cancellationToken)
{
if (value == null)
{
return;
}
this.outputValue = value;
// Assume the response in JSON
this.context.Response.ContentType = "application/json";
if (value is Stream streamResult)
{
using (streamResult)
{
await streamResult.CopyToAsync(this.context.Response.Body);
}
}
else if (value is byte[] bytes)
{
await this.context.Response.Body.WriteAsync(bytes, 0, bytes.Length);
}
else
{
string jsonResult = JsonSerializer.Serialize(value, JsonUtils.DefaultSerializerOptions);
await this.context.Response.WriteAsync(jsonResult, cancellationToken);
}
}