Skip to content
This repository has been archived by the owner on Dec 20, 2021. It is now read-only.

Commit

Permalink
Merge 83490c8 into c3a0823
Browse files Browse the repository at this point in the history
  • Loading branch information
MeroveeCharrue committed Apr 19, 2019
2 parents c3a0823 + 83490c8 commit 00807c4
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,17 +114,31 @@ At the end in the controller, you will have true json, xml for payload & integer

### Automatic binding route

**RREST** bind the route to a controller by following this convention:
**RREST** binds the route to a controller by following this convention:
* `POST /item/` -> `Controllers\Item#postAction`
* `GET /item/{itemId}/` -> `Controllers\Item#getAction`
* `GET /item/{itemId}/comment` -> `Controllers\Item\Comment#getAction`
* `PUT /item/{itemId}/comment/{commentId}` -> `Controllers\Item\Comment#putAction`

> note you can define the controller namespace (here Controllers) in the RREST\RREST constructor
> Note: You can define the controller namespace (here Controllers) in the RREST\RREST constructor
#### Ordering route

The order of API definitions matters. RREST will match the first definition that corresponds to the route called.

To use plain route as well as route with parameters with the same base, precedence should be as follow :
```raml
# First, endpoints with params, then plain endpoints.
/item/{itemId}
/item/archive
```

> If done in the other way, calling `GET /item/archive` would be matched to `/item/{itemId}`, with value "archive" for {itemId}.
> To prevent this, simply order endpoint definitions.
### Response

A `RREST\Response` is injecting into the controller with pre-filled values based on the APISpec or errors/exceptions that occur during the handling of a request.
A `RREST\Response` is injected into the controller with pre-filled values based on the APISpec or errors/exceptions that occur during the handling of a request.

You only need to fill response data to this object because the rest is configured:
* status code: 200 , 201 for `POST`, 40x ...
Expand Down

0 comments on commit 00807c4

Please sign in to comment.