@@ -390,7 +390,7 @@ class Definition {
390390 /**
391391 * A HTTP verb or <code>*</code>.
392392 */
393- private String verb ;
393+ private String method ;
394394
395395 /**
396396 * A path pattern.
@@ -447,25 +447,17 @@ public Definition(final @Nonnull String verb, final @Nonnull String pattern,
447447 /**
448448 * Creates a new route definition.
449449 *
450- * @param verb A HTTP verb or <code>*</code>.
450+ * @param method A HTTP verb or <code>*</code>.
451451 * @param pattern A path pattern.
452452 * @param filter A callback to execute.
453453 */
454- public Definition (final @ Nonnull String verb , final @ Nonnull String pattern ,
454+ public Definition (final @ Nonnull String method , final @ Nonnull String pattern ,
455455 final @ Nonnull Filter filter ) {
456- try {
457- requireNonNull (verb , "HTTP verb is required." );
458- Verb .valueOf (verb .toUpperCase ());
459- } catch (IllegalArgumentException ex ) {
460- if (!"*" .equals (verb )) {
461- throw new IllegalArgumentException ("Invalid HTTP verb: " + verb );
462- }
463- }
464456 requireNonNull (pattern , "A route path is required." );
465457 requireNonNull (filter , "A filter is required." );
466458
467- this .verb = verb .toUpperCase ();
468- this .compiledPattern = new RoutePattern (verb , pattern );
459+ this .method = method .toUpperCase ();
460+ this .compiledPattern = new RoutePattern (method , pattern );
469461 // normalized pattern
470462 this .pattern = compiledPattern .pattern ();
471463 this .filter = filter ;
@@ -518,10 +510,10 @@ public Definition(final @Nonnull String verb, final @Nonnull String pattern,
518510 * @param accept The <code>Accept</code> header.
519511 * @return A route or an empty optional.
520512 */
521- public @ Nonnull Optional <Route > matches (final @ Nonnull Verb verb ,
513+ public @ Nonnull Optional <Route > matches (final @ Nonnull String verb ,
522514 final @ Nonnull String path , final @ Nonnull MediaType contentType ,
523515 final @ Nonnull List <MediaType > accept ) {
524- RouteMatcher matcher = compiledPattern .matcher (verb .name () + path );
516+ RouteMatcher matcher = compiledPattern .matcher (verb .toUpperCase () + path );
525517 if (matcher .matches ()) {
526518 List <MediaType > result = MediaType .matcher (accept ).filter (this .produces );
527519 if (result .size () > 0 && canConsume (contentType )) {
@@ -535,10 +527,10 @@ public Definition(final @Nonnull String verb, final @Nonnull String pattern,
535527 }
536528
537529 /**
538- * @return HTTP verb or <code>*</code>
530+ * @return HTTP method or <code>*</code>.
539531 */
540- public @ Nonnull String verb () {
541- return verb ;
532+ public @ Nonnull String method () {
533+ return method ;
542534 }
543535
544536 /**
@@ -695,7 +687,7 @@ public List<MediaType> produces() {
695687 @ Override
696688 public String toString () {
697689 StringBuilder buffer = new StringBuilder ();
698- buffer .append (verb ()).append (" " ).append (pattern ()).append ("\n " );
690+ buffer .append (method ()).append (" " ).append (pattern ()).append ("\n " );
699691 buffer .append (" name: " ).append (name ()).append ("\n " );
700692 buffer .append (" consume: " ).append (consumes ()).append ("\n " );
701693 buffer .append (" produces: " ).append (produces ()).append ("\n " );
@@ -705,14 +697,14 @@ public String toString() {
705697 /**
706698 * Creates a new route.
707699 *
708- * @param verb A HTTP verb.
700+ * @param method A HTTP verb.
709701 * @param matcher A route matcher.
710702 * @param produces List of produces types.
711703 * @return A new route.
712704 */
713- private Route asRoute (final Verb verb , final RouteMatcher matcher ,
705+ private Route asRoute (final String method , final RouteMatcher matcher ,
714706 final List <MediaType > produces ) {
715- return new RouteImpl (filter , verb , matcher .path (), pattern , name , matcher .vars (), consumes ,
707+ return new RouteImpl (filter , method , matcher .path (), pattern , name , matcher .vars (), consumes ,
716708 produces );
717709 }
718710
@@ -746,8 +738,8 @@ public String path() {
746738 }
747739
748740 @ Override
749- public Verb verb () {
750- return route .verb ();
741+ public String method () {
742+ return route .method ();
751743 }
752744
753745 @ Override
@@ -965,15 +957,32 @@ interface Chain {
965957 void next (@ Nonnull Request req , @ Nonnull Response rsp ) throws Exception ;
966958 }
967959
960+ /**
961+ * Well known HTTP methods.
962+ */
963+ List <String > METHODS = ImmutableList .<String > builder ()
964+ .add (
965+ "GET" ,
966+ "POST" ,
967+ "PUT" ,
968+ "DELETE" ,
969+ "PATCH" ,
970+ "HEAD" ,
971+ "CONNECT" ,
972+ "OPTIONS" ,
973+ "TRACE"
974+ )
975+ .build ();
976+
968977 /**
969978 * @return Current request path.
970979 */
971980 String path ();
972981
973982 /**
974- * @return Current request verb .
983+ * @return Current HTTP method .
975984 */
976- Verb verb ();
985+ String method ();
977986
978987 /**
979988 * @return The currently matched pattern.
0 commit comments