ERRest In Depth

Version 37.1 by Pascal Robert on 2012/05/02 20:06

  • 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
    • ERXRest.strictMode
    • 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
    • ERXRest.maxEventsPerTransaction
  • JSON Schema
    • /something?schema=true

      public WOActionResults indexAction() {
      if (isSchemaRequest()) {
       return schemaResponse(showFilter());
      }
      protected boolean isSchemaRequest() {
       return request().stringFormValueForKey("schema") != null;
      }

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