Socket
Book a DemoInstallSign in
Socket

angular-httphook

Package Overview
Dependencies
Maintainers
1
Versions
1
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

angular-httphook

A lightweight http hook for angular

latest
Source
npmnpm
Version
0.1.0
Version published
Maintainers
1
Created
Source

angular-httphook

A lightweight http hook for angular

IDL

void httphook(
  RegExp method,
  RegExp uri,
  optional function requestHandler,
  optional function responseHandler
);
  • method is a matcher with RegExp, hooking only request method is matched.
  • uri is a matcher with RegExp, hooking only request uri is matched.
  • requestHandler is callback function that used to process hooked requests.
  • responseHandler is callback function that used to process hooked response.

requestHandler and responseHandler are optional.

Demo

<html ng-app="test">
<script src="bower_components/angular/angular.js"></script>
<script src="bower_components/angular-httphook/angular-httphook.js"></script>
<script>
angular.module('test', ['httphook']).run(['$http', 'httphook', function($http, httphook) {

  httphook.get(/^\/api/, function(req, res) {
    // Set a 200 response
    res.status = 200;
    res.statusText = 'OK';
    res.data = 'Hello World';
    // Do not launch
    return false;
  });

  $http.get('/api').then(function(e) {
    // Hello World
    console.log(e.data);
  });

}]);
</script>

Install

bower install angular-httphook

Reference

https://github.com/YanagiEiichi/xceptor

FAQs

Package last updated on 15 Apr 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.