Skip to content

squareteam/angular-fancy-url

Repository files navigation

angular-fancy-url Build Status

(Related Article)

Just do

app.service('myService', function($http) {
  // GET http://api.example.com/users
  return $http.get('api://users');
});

No more

app.service('myService', function($http, apiUrl) {
  // GET http://api.example.com/users
  return $http.get(apiUrl + '/users');
});
  • Flexibility — interceptors for the win !
  • Readability — no extras string concatenation or helper calls
  • “Testability”

Usage

bower install angular-fancy-url --save

then

angular.module('myApplication', [
   'fancyURL'
]).config(function($httpProvider, httpFancyURLProvider) {
   $httpProvider.interceptors.push('httpFancyURL');

   httpFancyURLProvider.use({
      'api' : 'http://api.example.com/',
   });
})

About

$http.get('api://users/1'); // human readable configured url

Resources

License

Stars

Watchers

Forks

Packages

No packages published