Skip to content
This repository was archived by the owner on Apr 12, 2024. It is now read-only.

Being able to override url in resource actions #2054

Closed
wants to merge 2 commits into from
Closed

Being able to override url in resource actions #2054

wants to merge 2 commits into from

Conversation

nolazybits
Copy link
Contributor

A pull request already existed (#1890)
but i found out that the url set up in the action would not have their params replaced.

This is what I intent to do here:

      var TypeItem = $resource('', {type: 'Order'}, {
          get: {
              method: 'GET',
              params: {type: 'Customer'},
              url: '/:type/:typeId'
          }
      });
      var item = TypeItem.get({typeId: 123});

will call /Customer/123

- modified regexp on params replacement  (test was failing on the last param of the url if it was the one ending the url string)
@IgorMinar
Copy link
Contributor

can you also add a test for scenario where no params are being replaced in the override url?

@IgorMinar
Copy link
Contributor

PR Checklist (Minor Feature)

  • Contributor signed CLA now or in the past (if you just signed, leave a comment here with your real name for cross reference)
  • Feature improves existing core functionality
  • API is compatible with existing Angular apis and relevant standards (if applicable)
  • PR doesn't contain a breaking change
  • PR contains unit tests
  • PR contains e2e tests (if suitable)
  • PR contains documentation update
  • PR passes all tests on Travis (sanity)
  • PR passes all tests on ci.angularjs.org (cross-browser compatibility)
  • PR is rebased against recent master
  • PR is squashed into one commit per logical change
  • PR's commit messages are descriptive and allows us to autogenerate release notes (required commit message format)
  • All changes requested in review have been implemented

- added test when no url params are set on the action
@nolazybits
Copy link
Contributor Author

@IgorMinar Done.
Btw thanks for the quick reply :)

@nolazybits
Copy link
Contributor Author

For the CLA:

  • real name Xavier MARTIN

@ghost ghost assigned IgorMinar Feb 27, 2013
@IgorMinar
Copy link
Contributor

I made some more tweaks, added docs (please don't forget about those in the future) and broke the tests into separate its.

the final change landed as 60f1f09

thanks!

@IgorMinar IgorMinar closed this Feb 27, 2013
@nolazybits
Copy link
Contributor Author

Hello Igor,

Will keep this in mind for future pull request.
Cheers, and thanks for the fast integration, I can now switch back to angularjs master :)

@mariojunior
Copy link

Hello guys!
By the way, this feature is not working anymore?
I'm using Angular 1.1.5 and angular-resource-1.0.1 and is not working as expected:
(pseudo-code):

var UserResource = $resource("http://localhost:8080/mycontext/api/user",
{ //* GET, POST, DELETE for /api/user endpoint working perfectly.
}
{ //
* but if I call UserResource.login(userObj) that's NOT firing against /api/user/login endpoint.
login: {method: 'POST', isArray: false, url: 'http://localhost:8080/mycontext/api/user/login'},
logout: {method: 'POST', isArray: false, url: 'http://localhost:8080/mycontext/api/user/logout'}
}

@mariojunior
Copy link

switched to angular-resource-1.0.7.min.js and is not working as expected yet.
Am I doing something wrong? Thanks.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants