Changes for page ERRest In Depth

Last modified by Pascal Robert on 2012/06/10 16:01

From version 26.1
edited by Pascal Robert
on 2012/03/11 20:51
Change comment: There is no comment for this version
To version 33.1
edited by Pascal Robert
on 2012/06/10 12:18
Change comment: There is no comment for this version

Summary

Details

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