|
|
|
|
604
|
- "pageLimits": Restricts list operations to prevent database scraping
|
604
|
- "pageLimits": Restricts list operations to prevent database scraping
|
605
|
- "joinLimits": Restricts join parameters to prevent database scraping
|
605
|
- "joinLimits": Restricts join parameters to prevent database scraping
|
606
|
- "customization": Provides handlers for request and response customization
|
606
|
- "customization": Provides handlers for request and response customization
|
|
|
607
|
+- "xml": Translates all input and output from JSON to XML
|
607
|
|
608
|
|
608
|
The "middlewares" config parameter is a comma separated list of enabled middlewares.
|
609
|
The "middlewares" config parameter is a comma separated list of enabled middlewares.
|
609
|
You can tune the middleware behavior using middleware specific configuration parameters:
|
610
|
You can tune the middleware behavior using middleware specific configuration parameters:
|
|
|
|
|
667
|
- "joinLimits.records": The maximum number of records returned for a joined entity ("1000")
|
668
|
- "joinLimits.records": The maximum number of records returned for a joined entity ("1000")
|
668
|
- "customization.beforeHandler": Handler to implement request customization ("")
|
669
|
- "customization.beforeHandler": Handler to implement request customization ("")
|
669
|
- "customization.afterHandler": Handler to implement response customization ("")
|
670
|
- "customization.afterHandler": Handler to implement response customization ("")
|
|
|
671
|
+- "xml.objectElement": The XML element name to use for objects ("object")
|
670
|
|
672
|
|
671
|
If you don't specify these parameters in the configuration, then the default values (between brackets) are used.
|
673
|
If you don't specify these parameters in the configuration, then the default values (between brackets) are used.
|
672
|
|
674
|
|
|
|
|
|
1036
|
|
1038
|
|
1037
|
The above example will add a header "X-Time-Taken" with the number of seconds the API call has taken.
|
1039
|
The above example will add a header "X-Time-Taken" with the number of seconds the API call has taken.
|
1038
|
|
1040
|
|
|
|
1041
|
+### XML middleware
|
|
|
1042
|
+
|
|
|
1043
|
+You may use the "xml" middleware to translate input and output from JSON to XML. This request:
|
|
|
1044
|
+
|
|
|
1045
|
+ GET /records/posts/1?format=xml
|
|
|
1046
|
+
|
|
|
1047
|
+Gives this outputs (it uses a "format" query parameter):
|
|
|
1048
|
+
|
|
|
1049
|
+ <object><id>1</id><user_id>1</user_id><category_id>1</category_id><content>blog started</content></object>
|
|
|
1050
|
+
|
|
|
1051
|
+This functionality is disabled by default and must be enabled using the "middlewares" configuration setting.
|
|
|
1052
|
+
|
1039
|
### File uploads
|
1053
|
### File uploads
|
1040
|
|
1054
|
|
1041
|
File uploads are supported through the [FileReader API](https://caniuse.com/#feat=filereader), check out the [example](https://github.com/mevdschee/php-crud-api/blob/master/examples/clients/upload/vanilla.html).
|
1055
|
File uploads are supported through the [FileReader API](https://caniuse.com/#feat=filereader), check out the [example](https://github.com/mevdschee/php-crud-api/blob/master/examples/clients/upload/vanilla.html).
|