Now, Please Meander

    ng-http-rewrite

    0.1.1 • Public • Published

    ngHttpRewrite

    This is just a simple module that allows users to rewrite outgoing urls in Angular without having to jump through hoops of creating interceptors. The idea behind this is that your entire project can use a simple prefix like /api in all of their urls and have them all rewritten at one location. This prevents code duplication.

    Installation

    npm i ng-http-rewrite --save

    Usage

    // This is not a CommonJS module. If you're using Webpack just load it like this.
    var angular = require('angular');
    require('ng-http-rewrite');
     
    angular.module('yourModule', ['lambdaexpression.httpRewrite'])
      .config(function(httpRewriteProvider) {
        // Note that the first argument is a regular expression.
        // Do *not* include trailing slashes unless you want them to be removed.
        // Everything that matches the regular expression is replaced with the
        // secondary string.
        httpRewriteProvider.rewrite(/^\/api/, '/my/rewritten/location');
      });

    There is no run-time API for the url rewriter and it only works on outgoing $http requests. It will not re-write the urls of incoming requests (not would it make any sense to). Check tests for usage if you really need to.

    Any issues?

    Feel free to open an issue if you have any issues or feature requests. Pull requests are also accepted providing you have tests (we're using jasmine/karma).

    Keywords

    Install

    npm i ng-http-rewrite

    DownloadsWeekly Downloads

    2

    Version

    0.1.1

    License

    ISC

    Last publish

    Collaborators

    • danpantry