Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Update RestRPCFilters.groovy

  • Loading branch information...
commit 7bceb287937bc09d02ce7f10191da0c6988688c6 1 parent e2b9108
@orubel authored
Showing with 45 additions and 33 deletions.
  1. +45 −33 grails-app/conf/RestRPCFilters.groovy
View
78 grails-app/conf/RestRPCFilters.groovy
@@ -31,45 +31,57 @@ class RestRPCFilters {
if(!newModel.isEmpty()){
switch(params.format){
case 'JSON':
- render text:newModel as JSON, contentType: "application/json"
+ render(text:newModel as JSON, contentType: "application/json")
+ return false
break
case 'XML':
- render text:newModel as XML, contentType: "application/xml"
+ render(text:newModel as XML, contentType: "application/xml")
+ return false
break
}
}
}
break
- case RpcMethod.PUT:
- if(restRPCService.isRequestMatch('PUT')){
- switch(params.format){
- case 'JSON':
- case 'XML':
- return response.status
- break
- }
- }
- break
- case RpcMethod.POST:
- if(restRPCService.isRequestMatch('POST')){
- switch(params.format){
- case 'JSON':
- case 'XML':
- return response.status
- break
- }
- }
- break
- case RpcMethod.DELETE:
- if(restRPCService.isRequestMatch('DELETE')){
- switch(params.format){
- case 'JSON':
- case 'XML':
- return response.status
- break
- }
- }
- break
+ case RpcMethod.PUT:
+ def newModel = restRPCService.formatModel(model)
+ if(restRPCService.isRequestMatch('PUT')){
+ switch(params.format){
+ case 'JSON':
+ render(text:newModel as JSON, contentType: "application/json")
+ break
+ case 'XML':
+ render(text:newModel as XML, contentType: "application/xml")
+ return false
+ break
+ }
+ }
+ break
+ case RpcMethod.POST:
+ println("POST METHOD")
+ def newModel = restRPCService.formatModel(model)
+ if(restRPCService.isRequestMatch('POST')){
+ switch(params.format){
+ case 'JSON':
+ render(text:newModel as JSON, contentType: "application/json")
+ return false
+ break
+ case 'XML':
+ render(text:newModel as XML, contentType: "application/xml")
+ return false
+ break
+ }
+ }
+ break
+ case RpcMethod.DELETE:
+ if(restRPCService.isRequestMatch('DELETE')){
+ switch(params.format){
+ case 'JSON':
+ case 'XML':
+ return response.status
+ break
+ }
+ }
+ break
}
return false
} else {
@@ -82,4 +94,4 @@ class RestRPCFilters {
}
}
}
-}
+}
Please sign in to comment.
Something went wrong with that request. Please try again.