ContentNegotiateModule.js
21 lines
| 841 B
| application/javascript
|
JavascriptLexer
|
|
r0 | define(["dojo/_base/declare", "dojo/when", "./BaseResponse", "./ModelResponse"],function(declare,when, BaseResponse, ModelResponse) { | |
| return declare(null,{ | |||
| invoke: function(httpRequest, next) { | |||
| return when(next(), function(result) { | |||
| if (!(result instanceof BaseResponse) ){ | |||
| result = new ModelResponse(result); | |||
| } | |||
| if (!(result instanceof ModelResponse)) | |||
| return result; | |||
| result.presenter = { | |||
| present: JSON.stringify, | |||
| contentType: "application/json; charset=utf-8" | |||
| }; | |||
| // TODO select presenter and assing it to result.presenter | |||
| return result; | |||
| }); | |||
| } | |||
| }); | |||
| }); |
