Skip to content
This repository has been archived by the owner on Jan 9, 2025. It is now read-only.

Commit

Permalink
fix(restapi): fix response body missing problem (#222)
Browse files Browse the repository at this point in the history
Because

- `restapi` component would miss the response body if it is not a JSON

This commit

- check whether the body is nil, if true, assign the response as a
string
- maintain body in JSON structure to avoid frontend render overhead
- as the frontend would split the plain text into thousands of div if
the body is large
  • Loading branch information
YCK1130 authored Jul 19, 2024
1 parent c61b134 commit 47a28dd
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions application/restapi/v0/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,13 @@ func (e *execution) Execute(_ context.Context, inputs []*structpb.Struct) ([]*st
taskOut.StatusCode = resp.StatusCode()
taskOut.Header = resp.Header()

if taskOut.Body == nil {
// Maintain a JSON structure for the output to avoid frontend render overhead.
taskOut.Body = map[string]interface{}{
"response": resp.String(),
}
}

output, err := base.ConvertToStructpb(taskOut)
if err != nil {
return nil, err
Expand Down

0 comments on commit 47a28dd

Please sign in to comment.