Skip to content

Commit

Permalink
upgrade required and /graphql
Browse files Browse the repository at this point in the history
  • Loading branch information
enisdenjo committed May 11, 2023
1 parent 784ea0b commit b67aa89
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 3 deletions.
2 changes: 1 addition & 1 deletion benchmark/servers/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ const handler = makeHandler({ schema });
serve(
(req: Request) => {
if (req.headers.get('upgrade') != 'websocket') {
return new Response(null, { status: 501 });
return new Response('Upgrade Required', { status: 426 });
}
const { socket, response } = Deno.upgradeWebSocket(req, {
protocol: GRAPHQL_TRANSPORT_WS_PROTOCOL,
Expand Down
6 changes: 5 additions & 1 deletion src/use/deno.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ export interface Extra {
*
* serve(
* (req: Request) => {
* const [path, _search] = req.url.split('?');
* if (!path.endsWith('/graphql')) {
* return new Response('Not Found', { status: 404 });
* }
* if (req.headers.get('upgrade') != 'websocket') {
* return new Response(null, { status: 501 });
* return new Response('Upgrade Required', { status: 426 });
* }
* const { socket, response } = Deno.upgradeWebSocket(req, {
* protocol: GRAPHQL_TRANSPORT_WS_PROTOCOL,
Expand Down
6 changes: 5 additions & 1 deletion website/src/pages/get-started.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,12 @@ const handler = makeHandler({ schema });

serve(
(req: Request) => {
const [path, _search] = req.url.split('?');
if (!path.endsWith('/graphql')) {
return new Response('Not Found', { status: 404 });
}
if (req.headers.get('upgrade') != 'websocket') {
return new Response(null, { status: 501 });
return new Response('Upgrade Required', { status: 426 });
}
const { socket, response } = Deno.upgradeWebSocket(req, {
protocol: GRAPHQL_TRANSPORT_WS_PROTOCOL,
Expand Down

0 comments on commit b67aa89

Please sign in to comment.