-
Notifications
You must be signed in to change notification settings - Fork 603
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
discussion: Make std/http use web standard FetchEvent #673
Comments
This is not a good idea. For example on I have a proposal for the |
@samuelgozi This is incorrect. Please read https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent. There is precedent for this approach in the web platform service worker and on platforms like Cloudflare Workers.
For fetch you can also do |
@lucacasonato I didn't disagree on the But what about: I'm just trying to understand, but don't feel obligated to explain. |
If needed, we could (should?) use a Example: console.log(request); // Request { ... }
console.log(request[Deno.extension].conn); // Deno.Conn { ... } |
The user manually creates this response using For the request they should just equal to what service workers do (). I would have to check the spec what exactly they do with these properties (
I agree, but the |
So I just looked at this, and we can't implement it properly without moving the entire http handler into If we decide to switch to a rust based http server to increase perf we can use this approach for a possible Something that would be possible is just not using |
I'm coding a server for an app, and I ended up doing something very similar to this(literally right now). Not exactly following the fetch standard, but it does make sense to warp the request and response in a class with methods like |
Yes I'm in favor of this. https://googlechrome.github.io/samples/service-worker/basic/ |
So I did some more testing with this and it looks pretty doable actually. Have a POC based on the current std/http here: https://github.com/lucacasonato/deno-fetchevent. I can implement it in std without too much trouble I think. The only somewhat annoying thing is that this requires that we add a We should also fix the Response constructor to match spec before this change happens. This should become really simple once |
Raising this here because the design of the eventual built-in HTTP server is discussed in this issue. I think we should go with a custom |
I am looking forward for |
Closing as https://github.com/denoland/deno_std/discussions/1034 has more detailed suggestions. |
I know this is really late for such a change, but I think it's important to discuss and I think I can implement this in a couple of hours.
I propose to switch the server in
std/http
from using a proprietaryServerRequest
(andServerResponse
, denoland/deno#4861) to use the web standardFetchEvent
,Request
andResponse
that is used byfetch
and service workers (https://developer.mozilla.org/en-US/docs/Web/API/FetchEvent).This would mean that
Server
changes from aAsyncIterableIterator<ServerRequest>
to aAsyncIterableIterator<FetchEvent>
. This would slightly change the semantics of usingServer
, but it would reduce complexity and we would provide an interface that is web compatible and familiar to many web devs.The text was updated successfully, but these errors were encountered: