UNPKG

winterspec

Version:

Write Winter-CG compatible routes with filesystem routing and tons of features

8 lines (7 loc) 251 B
import { MethodNotAllowedError } from "./http-exceptions.js"; export const withMethods = (methods) => (req, ctx, next) => { if (!methods.includes(req.method)) { throw new MethodNotAllowedError(methods); } return next(req, ctx); };