ERRest In Depth
- ERXRestContext
- contains the editing context and an userInfo dictionnary
- will be populated with er.rest.dateFormat, er.rest.timestampFormatter and er.rest.timestampFormat (read only for non-HTML responses)
- want to change the time format for a specific controller?
protected ERXRestContext createRestContext() {
ERXRestContext restContext = new ERXRestContext(editingContext());
restContext.setUserInfoForKey("yyyy-MM-dd", "er.rest.dateFormat");
restContext.setUserInfoForKey("yyyy-MM-dd", "er.rest.timestampFormat");
return restContext;
}
- you just need to override createRestContext() in your controller if you want to add other stuff to the context (a user, etc.)
- Properties
- ERXRest.idKey (ERXRestFormatDelegate)
- (default "id") Override this property if you want to use a different key for the 'id' attribute ERXRest.typeKey
- ERXRest.nilKey (ERXRestFormatDelegate)
- ERXRest.writeNilKey (ERXRestFormatDelegate)
- ERXRest.pluralEntityNames (ERXRestFormatDelegate)
- ERXRest.writeTypeKey (ERXRestFormatDelegate)
- ERXRest.suppressTypeAttributesForSimpleTypes (ERXXmlRestWriter)
- (default "false") If set to true, primitive types, like type = "datetime", won't be added to the output
- ERXRest.strictMode
- In ERXMissingRouteController: (default "true") If set to true, status code in the response will be 405 Not Allowed, if set to false, status code will be 404 Not Found
- In ERXRouteController: (default "true") If set to true, status code in the response will be 405 Not Allowed, if set to false, status code will be 404 Not Found
- ERXRouteResults: (default "true") If set to true, creating a ressource will return status code 201 Created, if set to false, will return 200 OK
- ERXRest.pluralEntityNames (ERXRouteRequestHandler)
- ERXRest.routeCase (ERXRouteRequestHandler)
- ERXRest.lowercaseEntityNames (ERXRouteRequestHandler)
- ERXRest.parseUnknownExtensions (ERXRouteRequestHandler)
- (default "true") If set to "false", will return a 404 status code if the format doesn't exist
- ERXRest.missingControllerName (ERXRouteRequestHandler)
- (default "ERXMissingRouteController") Allow you to specify which controller to use when a route doesn't exist
- er.rest.rfcDateFormat
- er.rest.dateFormat
- er.rest.dateFormat.primary
- er.rest.dateFormat.secondary
- er.rest.dateFormatter
- er.rest.timestampFormat
- er.rest.timestampFormat.primary
- er.rest.timestampFormat.secondary
- er.rest.timestampFormatter
- er.rest.rfcDateFormat
- ERXRest.transactionsEnabled (default 'false') ERXRestTransactionRequestAdaptor
- ERXRest.maxEventsPerTransaction (default '50') ERXRestTransactionRequestAdaptor
- ERXRest.accessControlAllowRequestHeaders (ERXRouteController)
- ERXRest.accessControlAllowRequestMethods (ERXRouteController)
- ERXRest.defaultFormat (ERXRouteController)
- (default "xml") Allow you to set the default format for all of your REST controllers
- ERXRest.allowWindowNameCrossDomainTransport (ERXRouteController)
- ERXRest.accessControlMaxAge (ERXRouteController)
- (default 1728000) This header indicates how long the results of a preflight request can be cached. For an example of a preflight request, see the above examples.
- ERXRest.accessControlAllowOrigin (ERXRouteController)
- Set the value to '' to enable all origins. See https://developer.mozilla.org/En/HTTP_access_control#Access-Control-Allow-Origin
- ERXRest.idKey (ERXRestFormatDelegate)
- JSON Schema
- /something?schema=true
public WOActionResults indexAction() {
if (isSchemaRequest()) {
return schemaResponse(showFilter());
}
protected boolean isSchemaRequest() {
return request().stringFormValueForKey("schema") != null;
}
- /something?schema=true
Same Origin policy
Transactions
HTML vs other formats
Response representation
Missing route
Missing object
POJO objects
Headers
Caching
Adding new format
Security
strictMode
Workflow
Query arguments and RXRestFetchSpecification
ERXRestNameRegistry
MapClassDescription / NSDictionaryClassDescription
ERXRestUtils
Properties
er.rest.dateFormat
er.rest.timestampFormat
er.rest.rfcDateFormat
request > route
Application(ERXApplication).dispatchRequest(WORequest) line: 2051
ERXRouteRequestHandler(WOActionRequestHandler).handleRequest(WORequest) line: 221
ERXRouteRequestHandler.getRequestHandlerPathForRequest(WORequest) line: 782
ERXRouteRequestHandler(WOActionRequestHandler).handleRequest(WORequest) line: 259
PagesController(ERXRouteController).performActionNamed(String) line: 1328
PagesController(ERXRouteController).performActionNamed(String, boolean) line: 1385
PagesController(ERXRouteController).performRouteActionNamed(String) line: 1510
PagesController(ERXRouteController).performActionWithArguments(Method, Object...) line: 1559
...
PagesController.mainPageAction() line: 20
ERXRouteRequestHandler
Properties | |
ERXRest.missingControllerName | (default "ERXMissingRouteController") |
ERXRest.parseUnknownExtensions | ERXRest.parseUnknownExtensions |
ERXRest.pluralEntityNames | ERXRest.pluralEntityNames |
ERXRest.routeCase | ERXRest.routeCase |
ERXRest.lowercaseEntityNames | ERXRest.lowercaseEntityNames |
ERXMissingRouteController is the controller that is used when no route can be found. It's "missing" action is loaded.
Properties | ||
ERXRest.strictMode | ERXRest.strictMode | ERXRouteController |
Properties
ERXRest.accessControlAllowRequestHeaders
ERXRest.accessControlAllowRequestMethods
ERXRest.defaultFormat
ERXRest.strictMode
ERXRest.allowWindowNameCrossDomainTransport
ERXRest.accessControlMaxAge
ERXRest.accessControlAllowOrigin