Skip to content

Commit

Permalink
check request method
Browse files Browse the repository at this point in the history
  • Loading branch information
StigNygaard committed Oct 22, 2024
1 parent dbfbfb4 commit 99c179b
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,10 @@ Deno.serve(async (req: Request, info: Deno.ServeHandlerInfo) => {

// The "Router"...
let response: Response;
if (/^\/proxy-api\/?$/.test(pathname)) {
if (req.method !== 'GET') {
return new Response('Not found', { status: 404, statusText: `Method ${req.method} not supported here`, headers: myHeaders});
// for supporting other methods, see f.ex: https://youtu.be/p541Je4J_ws?si=-tWmB355467gtFIP
} else if (/^\/proxy-api\/?$/.test(pathname)) {
// The "proxy API" - https://lastfm-widgets.deno.dev/proxy-api
const result = await proxyApi(url.searchParams, req.headers, info);
response = new Response(result.body, {headers: myHeaders, ...result.options});
Expand Down

0 comments on commit 99c179b

Please sign in to comment.