add method
Implementation
void add(String method, String route, Function handler,{Middleware? middleware}) {
if (!isHttpMethod(method)) {
throw ArgumentError.value(
method, 'method', 'expected a valid HTTP method');
}
if (route.isEmpty || !route.startsWith('/')) {
throw ArgumentError.value(
method, 'route', 'path must begin with "/" in path "$route"');
}
method = method.toUpperCase();
if (method == 'GET') {
// Handling in a 'GET' request without handling a 'HEAD' request is always
// wrong, thus, we add a default implementation that discards the body.
_addRoute('HEAD', route, handler, middleware: _removeBody);
}
_addRoute(method, route, handler,middleware:middleware);
}