angular/angular.js — pull request #1045 by ajoslin (2012-06-12 22:27:15+00:00)
Title: Extended customizability of $resource

Added an option to $resource's `action` parameters. The user can define a custom httpConfig and a custom parseResponse function. These allow the user to work with a lot more systems (sending custom headers through action.httpConfig and parsing weird responses with parseResponse).

Example use case. these additions let me use www.parse.com and $resource together easily.
```coffeescript
parseHttpConfig = { headers: parseHeaders } #Our custom headers to use Parse
ParseResource = $resource(
'https://api.parse.com/1/classes/:class/:id'
{
class: '@class'
id: '@id'
},
{
get : { method: 'GET', httpConfig: parseHttpConfig }
create: { method: 'POST', httpConfig: parseHttpConfig }
save : { method: 'PUT', httpConfig: parseHttpConfig }
query : {
httpConfig: parseHttpConfig
isArray: true
# Parse's response from a query gives response.data.result,
# a parseResponse function allows us to use this
parseResponse: (response) ->
return response.data.result;
}
remove: { httpConfig: parseHttpConfig }
}
)
```

I don't know if action.httpConfig and action.parseResponse are the best names, but I think the idea of adding these two simple things adds a lot more flexibility to $resource.