Wiki source code of ERRest In Depth
Version 40.1 by Pascal Robert on 2012/05/02 21:50
Hide last authors
| author | version | line-number | content |
|---|---|---|---|
| |
37.1 | 1 | * ERXRestContext |
| 2 | ** contains the editing context and an userInfo dictionnary | ||
| 3 | ** will be populated with er.rest.dateFormat, er.rest.timestampFormatter and er.rest.timestampFormat (read only for non-HTML responses) | ||
| 4 | *** want to change the time format for a specific controller? | ||
| 5 | |||
| 6 | {{code}} | ||
| 7 | |||
| 8 | protected ERXRestContext createRestContext() { | ||
| 9 | ERXRestContext restContext = new ERXRestContext(editingContext()); | ||
| 10 | restContext.setUserInfoForKey("yyyy-MM-dd", "er.rest.dateFormat"); | ||
| 11 | restContext.setUserInfoForKey("yyyy-MM-dd", "er.rest.timestampFormat"); | ||
| 12 | return restContext; | ||
| 13 | } | ||
| 14 | |||
| 15 | {{/code}} | ||
| 16 | |||
| 17 | * | ||
| 18 | ** you just need to override createRestContext() in your controller if you want to add other stuff to the context (a user, etc.) | ||
| 19 | * Properties | ||
| 20 | ** ERXRest.idKey (ERXRestFormatDelegate) | ||
| |
39.1 | 21 | *** (default "id") Override this property if you want to use a different key for the 'id' attribute** ERXRest.typeKey** |
| |
37.1 | 22 | ** ERXRest.nilKey (ERXRestFormatDelegate) |
| 23 | ** ERXRest.writeNilKey (ERXRestFormatDelegate) | ||
| 24 | ** ERXRest.pluralEntityNames (ERXRestFormatDelegate) | ||
| 25 | ** ERXRest.writeTypeKey (ERXRestFormatDelegate) | ||
| |
39.1 | 26 | ** ERXRest.suppressTypeAttributesForSimpleTypes (ERXXmlRestWriter) |
| 27 | *** (default "false") If set to true, primitive types, like type = "datetime", won't be added to the output | ||
| |
37.1 | 28 | ** ERXRest.strictMode |
| |
39.1 | 29 | *** 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 |
| 30 | *** 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 | ||
| 31 | *** ERXRouteResults: (default "true") If set to true, creating a ressource will return status code 201 Created, if set to false, will return 200 OK | ||
| |
37.1 | 32 | ** ERXRest.pluralEntityNames (ERXRouteRequestHandler) |
| 33 | ** ERXRest.routeCase (ERXRouteRequestHandler) | ||
| 34 | ** ERXRest.lowercaseEntityNames (ERXRouteRequestHandler) | ||
| 35 | ** ERXRest.parseUnknownExtensions (ERXRouteRequestHandler) | ||
| 36 | *** (default "true") If set to "false", will return a 404 status code if the format doesn't exist | ||
| 37 | ** ERXRest.missingControllerName (ERXRouteRequestHandler) | ||
| 38 | *** (default "ERXMissingRouteController") Allow you to specify which controller to use when a route doesn't exist | ||
| 39 | ** er.rest.rfcDateFormat | ||
| 40 | ** er.rest.dateFormat | ||
| 41 | ** er.rest.dateFormat.primary | ||
| 42 | ** er.rest.dateFormat.secondary | ||
| 43 | ** er.rest.dateFormatter | ||
| 44 | ** er.rest.timestampFormat | ||
| 45 | ** er.rest.timestampFormat.primary | ||
| 46 | ** er.rest.timestampFormat.secondary | ||
| 47 | ** er.rest.timestampFormatter | ||
| 48 | ** er.rest.rfcDateFormat | ||
| |
39.1 | 49 | ** ERXRest.transactionsEnabled (default 'false') ERXRestTransactionRequestAdaptor |
| 50 | ** ERXRest.maxEventsPerTransaction (default '50') ERXRestTransactionRequestAdaptor | ||
| 51 | ** ERXRest.accessControlAllowRequestHeaders (ERXRouteController) | ||
| 52 | ** ERXRest.accessControlAllowRequestMethods (ERXRouteController) | ||
| 53 | ** ERXRest.defaultFormat (ERXRouteController) | ||
| 54 | *** (default "xml") Allow you to set the default format for all of your REST controllers | ||
| 55 | ** ERXRest.allowWindowNameCrossDomainTransport (ERXRouteController) | ||
| 56 | ** ERXRest.accessControlMaxAge (ERXRouteController) | ||
| 57 | *** (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. | ||
| 58 | ** ERXRest.accessControlAllowOrigin (ERXRouteController) | ||
| 59 | *** Set the value to '**' to enable all origins. See https:~/~/developer.mozilla.org/En/HTTP_access_control#Access-Control-Allow-Origin** | ||
| |
37.1 | 60 | * JSON Schema |
| 61 | ** {{code}} | ||
| 62 | /something?schema=true | ||
| 63 | |||
| 64 | public WOActionResults indexAction() { | ||
| 65 | if (isSchemaRequest()) { | ||
| 66 | return schemaResponse(showFilter()); | ||
| 67 | } | ||
| 68 | protected boolean isSchemaRequest() { | ||
| 69 | return request().stringFormValueForKey("schema") != null; | ||
| 70 | } | ||
| 71 | {{/code}} | ||
| 72 | |||
| 73 | Same Origin policy | ||
| 74 | Transactions | ||
| 75 | HTML vs other formats | ||
| 76 | Response representation | ||
| 77 | Missing route | ||
| 78 | Missing object | ||
| 79 | POJO objects | ||
| 80 | Headers | ||
| 81 | Caching | ||
| 82 | Adding new format | ||
| 83 | Security | ||
| 84 | strictMode | ||
| 85 | Workflow | ||
| 86 | Query arguments and RXRestFetchSpecification | ||
| 87 | ERXRestNameRegistry | ||
| 88 | MapClassDescription / NSDictionaryClassDescription | ||
| 89 | |||
| 90 | ERXRestUtils | ||
| 91 | Properties | ||
| 92 | er.rest.dateFormat | ||
| 93 | er.rest.timestampFormat | ||
| 94 | er.rest.rfcDateFormat | ||
| 95 | |||
| |
31.1 | 96 | request > route |
| 97 | |||
| |
4.1 | 98 | Application(ERXApplication).dispatchRequest(WORequest) line: 2051 |
| 99 | ERXRouteRequestHandler(WOActionRequestHandler).//handleRequest(WORequest) line: 221 | ||
| |
27.1 | 100 | ERXRouteRequestHandler.getRequestHandlerPathForRequest(WORequest) line: 782// |
| |
4.1 | 101 | |
| |
27.1 | 102 | ERXRouteRequestHandler(WOActionRequestHandler).//handleRequest(WORequest) line: 259 |
| 103 | PagesController(ERXRouteController).performActionNamed(String) line: 1328 | ||
| 104 | PagesController(ERXRouteController).performActionNamed(String, boolean) line: 1385 | ||
| 105 | PagesController(ERXRouteController).performRouteActionNamed(String) line: 1510 | ||
| 106 | PagesController(ERXRouteController).performActionWithArguments(Method, Object...) line: 1559 | ||
| |
4.1 | 107 | ... |
| |
27.1 | 108 | PagesController.mainPageAction() line: 20// |
| 109 | |||
| 110 | == ERXRouteRequestHandler == | ||
| 111 | |||
| 112 | | **Properties** | ||
| 113 | | ERXRest.missingControllerName | (default "ERXMissingRouteController") | ||
| 114 | \\ | ||
| 115 | | ERXRest.parseUnknownExtensions | ERXRest.parseUnknownExtensions | ||
| 116 | \\ | ||
| 117 | | ERXRest.pluralEntityNames | ERXRest.pluralEntityNames | ||
| 118 | \\ | ||
| 119 | | ERXRest.routeCase | ERXRest.routeCase | ||
| 120 | \\ | ||
| 121 | | ERXRest.lowercaseEntityNames | ERXRest.lowercaseEntityNames | ||
| 122 | |||
| 123 | ERXMissingRouteController is the controller that is used when no route can be found. It's "missing" action is loaded. | ||
| 124 | |||
| 125 | | **Properties** | ||
| |
29.1 | 126 | | ERXRest.strictMode | ERXRest.strictMode |
| 127 | \\ | | ||
| |
27.1 | 128 | ERXRouteController |
| |
35.1 | 129 | |
| 130 | Properties | ||
| 131 | |||
| 132 | ERXRest.accessControlAllowRequestHeaders | ||
| 133 | ERXRest.accessControlAllowRequestMethods | ||
| 134 | ERXRest.defaultFormat | ||
| 135 | ERXRest.strictMode | ||
| 136 | ERXRest.allowWindowNameCrossDomainTransport | ||
| 137 | ERXRest.accessControlMaxAge | ||
| 138 | ERXRest.accessControlAllowOrigin |