Skip to content

Commit

Permalink
support HTTP PATCH method
Browse files Browse the repository at this point in the history
Fixes issues resthub#8
  • Loading branch information
bclozel committed Dec 12, 2013
1 parent afffa72 commit 8fdea50
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/main/java/org/resthub/web/springmvc/router/Router.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
*/
public class Router {

static Pattern routePattern = new Pattern("^({method}GET|POST|PUT|DELETE|OPTIONS|HEAD|\\*)[(]?({headers}[^)]*)(\\))?\\s+({path}.*/[^\\s]*)\\s+({action}[^\\s(]+)({params}.+)?(\\s*)$");
static Pattern routePattern = new Pattern("^({method}GET|POST|PUT|DELETE|PATCH|OPTIONS|HEAD|\\*)[(]?({headers}[^)]*)(\\))?\\s+({path}.*/[^\\s]*)\\s+({action}[^\\s(]+)({params}.+)?(\\s*)$");
/**
* Pattern used to locate a method override instruction
*/
static Pattern methodOverride = new Pattern("^.*x-http-method-override=({method}GET|PUT|POST|DELETE).*$");
static Pattern methodOverride = new Pattern("^.*x-http-method-override=({method}GET|PUT|POST|DELETE|PATCH).*$");

/**
* Timestamp the routes file was last loaded at.
Expand Down
1 change: 1 addition & 0 deletions src/test/resources/mappingroutes.conf
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ GET /http myTestController.httpActio
PUT /http myTestController.httpAction(type:'PUT')
POST /http myTestController.httpAction(type:'POST')
DELETE /http myTestController.httpAction(type:'DELETE')
PATCH /http myTestController.httpAction(type:'PATCH')
PUT /overridemethod myTestController.overrideMethod
GET /regex/{<[0-9]+>number} myTestController.regexNumberAction
GET /regex/{<[a-z]+>string} myTestController.regexStringAction
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ Feature: Handler mapping support
When I send the HTTP request "DELETE" "/http"
Then the request should be handled by "myTestController.httpAction"

Scenario: Mapping a PATCH request
Given I have a web application with the config locations "/simpleTestContext.xml"
When I send the HTTP request "PATCH" "/http"
Then the request should be handled by "myTestController.httpAction"

Scenario: Mapping a HEAD request
Given I have a web application with the config locations "/simpleTestContext.xml"
When I send the HTTP request "HEAD" "/http"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,11 @@ Feature: Reverse routing support
When I try to reverse route "myTestController.simpleAction"
Then I should get an action with path "/simpleaction"

Scenario: Reverse routing a simple URL with PATCH method
Given I have a route with method "PATCH" path "/simpleaction" action "myTestController.simpleAction"
When I try to reverse route "myTestController.simpleAction"
Then I should get an action with path "/simpleaction"

Scenario: Reverse routing an URL with params
Given I have routes:
| method | path | action | params |
Expand Down

0 comments on commit 8fdea50

Please sign in to comment.