angurl

An endpoint resolver for AngularJS


Keywords
angularjs, angular, endpoint, http, resolver, resolution, resolve, module
License
MIT
Install
bower install angurl

Documentation

angurl

angurl is an AngularJS module that helps you to resolve endpoints without a mess of constants in your app or a complex build process. You can define a dictionary of base URLs in a JSON file (or maybe an endpoint discovery service?), and they will be substituted in your request URLs.

Usage

First, add a reference to angurl.js to your app.

Next, add a baseUrlEndpoint constant to one of your app modules. For example:

angular
	.module("app")
	.constant("baseUrlEndpoint", "http://your.server/apis.json");

Now, add a reference to the angurl module. For example:

angular.module("app", ["angurl"]);

Finally, modify your request URLs to start with the keys specified in your base URL dictionary. For example:

$http.get("users-api/123");

Following the above examples, you should have a file at http://your.server/apis.json that looks like the following:

{
  "users-api": "http://some.server/api/users"
}