-
Notifications
You must be signed in to change notification settings - Fork 47
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
Support upgrading requests from the adapter #90
base: main
Are you sure you want to change the base?
Conversation
Hi @Kyiro Thanks for the PR. I'll take a look later! |
Hi @Kyiro, This looks good. Using First, could you write proper tests for this implementation? Second, while it's not necessary to include in this PR, I think passing app.get('/', (c) => {
const ip = c.env.incoming.socket.remoteAddress;
return c.text(`You are accessing from ${ip}`);
}) |
I wanted to write tests but the types fail for some reason.
|
Ah, there's a type mismatch. But could you still push the tests, even if they fail? |
Yeah, I guess but I don't have a way to test the tests. I'll see later |
|
||
export const createAdaptorServer = (options: Options): ServerType => { | ||
const fetchCallback = options.fetch | ||
const upgrade = options.upgrade !== false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This would always add the upgrade listener unless it is actively set to false. Is this intended?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, idk if it should be the default or not so i made it the default
These changes allow the upgrading to something like WebSockets from within Hono itself. Feel free to request any changes or even deny this PR as I'm not sure if it fits. The only big issue is that I don't think it supports HTTP2 at all.