Skip to content

Conversation

@TooTallNate
Copy link
Collaborator

@TooTallNate TooTallNate commented Feb 18, 2023

Previously there were two interfaces supported:

import { ServerRequest } from 'https://deno.land/[email protected]/http/server.ts';

export default function (request: ServerRequest) {
  console.log(request.url);
  request.respond({ body: '...' });
}
export default function (event: Deno.RequestEvent) {
  console.log(event.request.url);
  event.respondWith(new Response('...'));
}

Supporting both interfaces has been hard/hacky to maintain, and in 2023 there is a now a more standardized interface that also fits better with the Vercel style. This PR implements this new interface:

export default function (request: Request) {
  console.log(request.url);
  return new Response('...');
}

This new interface matches the Vercel Edge runtime syntax. The Request object is passed directly as the first parameter, and a Response instance is expected to be returned from the handler. The runtime is a lot cleaner because the legacy code has been removed. There are also less URL imports needed since Deno supports these standard classes directly (only base64 still needs to be imported).

Closes #104.

@vercel
Copy link

vercel bot commented Feb 18, 2023

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated
vercel-deno ✅ Ready (Inspect) Visit Preview 💬 Add your feedback Feb 18, 2023 at 2:35AM (UTC)

@TooTallNate TooTallNate changed the title Remove legacy interface Remove legacy interfaces, implement Vercel style interface Feb 18, 2023
@TooTallNate TooTallNate marked this pull request as ready for review February 19, 2023 09:17
@TooTallNate TooTallNate merged commit ce099e4 into main Feb 19, 2023
@TooTallNate TooTallNate deleted the web branch February 19, 2023 09:18
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.

Request body is always empty

1 participant