Allowed Methods
Easy · HTTP
In a Node server, req.method holds the HTTP method, like "GET" or "POST". If a route does not support a method, it should answer 405 Method Not Allowed with an Allow header listing the supported methods.
Write a function checkMethod(method, allowed):
- return null if method is in allowed (compare case-insensitively)
- otherwise return { status: 405, headers: { Allow: "..." } }, where Allow is allowed joined with ", " in its original order
Next: MIME Type from File Name