Skip to content

Commit 9e1f604

Browse files
committed
LDEV-5778 update REST documentation with fixes in 7
https://luceeserver.atlassian.net/browse/LDEV-5778
1 parent ed2d32b commit 9e1f604

File tree

1 file changed

+35
-0
lines changed

1 file changed

+35
-0
lines changed

docs/recipes/rest-services.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -142,6 +142,41 @@ http://localhost:8888/rest/metrics/system/timezone/name?locale=zh_TW
142142
http://localhost:8888/rest/metrics/system/timezone/utcHourOffset
143143
```
144144

145+
### REST request matching
146+
147+
When a REST request is processed, the matching rest method is found by looping thru all the functions, in the order defined within the CFC.
148+
149+
As in this example, specific `restPaths` should be placed before more generic, catch all `restPaths`.
150+
151+
Since 7.0.0.368
152+
153+
```cfml
154+
component restPath="/api/products" rest="true" {
155+
// GET /api/products/search?category=electronics
156+
remote function searchProducts( string category="" restArgSource="url" )
157+
httpMethod="GET" restPath="/search" {
158+
return {
159+
"message": "Product search completed",
160+
"filters": {
161+
"category": arguments.category
162+
},
163+
"method": "searchProducts"
164+
};
165+
}
166+
167+
// GET /api/products/123
168+
remote function getProduct( string productID restArgSource="path" )
169+
httpMethod="GET" restPath="/{productID}" {
170+
return {
171+
"message": "Single product retrieved",
172+
"productID": arguments.productID,
173+
"method": "getProduct"
174+
};
175+
}
176+
}
177+
```
178+
179+
Falling back to using function names as the REST Path, when no `restPath` is defined, was implemented in 7.0.0.366
145180

146181
### Configuring your web server to serve Lucee's REST services
147182

0 commit comments

Comments
 (0)