Files
points-mall/supplied-service/netlify/utils/method.ts
T
2026-07-28 10:54:47 +08:00

14 lines
323 B
TypeScript

import { handleOptions, methodNotAllowed } from './http.js'
export const guardMethod = (request: Request, allowedMethods: string[]) => {
if (request.method === 'OPTIONS') {
return handleOptions()
}
if (!allowedMethods.includes(request.method)) {
return methodNotAllowed(allowedMethods)
}
return null
}