Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: custom response in hono/streaming #2619

Closed

Conversation

Kanahiro
Copy link
Contributor

@Kanahiro Kanahiro commented May 6, 2024

related: https://github.com/orgs/honojs/discussions/2617

proposed signature

added new argument

// typeof stream()
(
  c: Context,
  cb: (stream: StreamingApi) => Promise<void>,
  onError?: (e: Error, stream: StreamingApi) => Promise<void>,
  responseFactory?: (c: Context, stream: StreamingApi) => Response // new!
): Response

same fix can be applied to streamText and streamSSE.

Author should do the followings, if applicable

  • Add tests
  • Run tests
  • bun denoify to generate files for Deno

@Kanahiro
Copy link
Contributor Author

Kanahiro commented May 6, 2024

Or this may be better?

// typeof stream()
(
  c: Context,
  cb: (stream: StreamingApi) => Promise<void>,
  options: {
    onError?: (e: Error, stream: StreamingApi) => Promise<void>,
    responseFactory?: (c: Context, stream: StreamingApi) => Response
  } = {}
): Response

@Kanahiro Kanahiro closed this May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

1 participant