diff --git a/pkgs/shelf_router/lib/src/router.dart b/pkgs/shelf_router/lib/src/router.dart index 8ba3c125..539fe872 100644 --- a/pkgs/shelf_router/lib/src/router.dart +++ b/pkgs/shelf_router/lib/src/router.dart @@ -15,12 +15,29 @@ import 'dart:collection' show UnmodifiableMapView; import 'dart:convert'; -import 'package:http_methods/http_methods.dart'; import 'package:meta/meta.dart' show sealed; import 'package:shelf/shelf.dart'; import 'trie.dart'; +/// Returns true if [method] is a valid HTTP method. +bool isHttpMethod(String method) { + switch (method.toUpperCase()) { + case 'GET': + case 'HEAD': + case 'POST': + case 'PUT': + case 'DELETE': + case 'CONNECT': + case 'OPTIONS': + case 'TRACE': + case 'PATCH': + return true; + default: + return false; + } +} + /// Get a URL parameter captured by the [Router]. @Deprecated('Use Request.params instead') String params(Request request, String name) { diff --git a/pkgs/shelf_router/pubspec.yaml b/pkgs/shelf_router/pubspec.yaml index 4a72727a..b50c9c0b 100644 --- a/pkgs/shelf_router/pubspec.yaml +++ b/pkgs/shelf_router/pubspec.yaml @@ -14,7 +14,6 @@ environment: sdk: ^3.3.0 dependencies: - http_methods: ^1.1.0 meta: ^1.3.0 shelf: ^1.0.0 diff --git a/pkgs/shelf_router_generator/lib/src/shelf_router_generator.dart b/pkgs/shelf_router_generator/lib/src/shelf_router_generator.dart index 85cbc5cd..2d2571db 100644 --- a/pkgs/shelf_router_generator/lib/src/shelf_router_generator.dart +++ b/pkgs/shelf_router_generator/lib/src/shelf_router_generator.dart @@ -22,13 +22,30 @@ import 'package:analyzer/dart/element/element.dart' import 'package:analyzer/dart/element/type.dart' show ParameterizedType; import 'package:build/build.dart' show BuildStep, log; import 'package:code_builder/code_builder.dart' as code; -import 'package:http_methods/http_methods.dart' show isHttpMethod; import 'package:shelf/shelf.dart' as shelf; import 'package:shelf_router/shelf_router.dart' as shelf_router; import 'package:shelf_router/src/router_entry.dart' // ignore: implementation_imports show RouterEntry; import 'package:source_gen/source_gen.dart' as g; +/// Returns true if [method] is a valid HTTP method. +bool isHttpMethod(String method) { + switch (method.toUpperCase()) { + case 'GET': + case 'HEAD': + case 'POST': + case 'PUT': + case 'DELETE': + case 'CONNECT': + case 'OPTIONS': + case 'TRACE': + case 'PATCH': + return true; + default: + return false; + } +} + // Type checkers that we need later const _routeType = g.TypeChecker.typeNamed( shelf_router.Route, diff --git a/pkgs/shelf_router_generator/pubspec.yaml b/pkgs/shelf_router_generator/pubspec.yaml index 105e1f7a..25ad3183 100644 --- a/pkgs/shelf_router_generator/pubspec.yaml +++ b/pkgs/shelf_router_generator/pubspec.yaml @@ -18,7 +18,6 @@ dependencies: build: ^4.0.0 build_config: ^1.2.0 code_builder: ^4.2.0 - http_methods: ^1.1.0 shelf: ^1.1.0 shelf_router: ^1.1.0 source_gen: ^4.0.1