Skip to content

Instantly share code, notes, and snippets.

View orgbx's full-sized avatar

orgbx

  • Spain / UK
View GitHub Profile
import { NgModule, Injectable } from '@angular/core';
import {
Request,
Response,
XHRBackend,
JSONPBackend,
RequestMethod
} from '@angular/http';
import {
NodeBackend,
@gund
gund / http-interceptor-concept.md
Last active September 19, 2022 01:08
Concept of Http Interceptor for Angular 2

First, we need to define interfaces with which we will work:

export interface Interceptable<T extends Interceptor<any, any>> {
  addInterceptor(interceptor: T): Interceptable<T>;
  removeInterceptor(interceptor: T): Interceptable<T>;
  clearInterceptors(interceptors?: T[]): Interceptable<T>;
}

export interface Interceptor<T, D> {