Class ProxyAbstract

Abstract Proxy base class to implement Http.Request interceptors, on the client side. By extending this abstract base class and providing the extending class to the Linker, e.g., by Targeting it, the class's handle method will be called with the Http.Request details (which could have been modified by a previous Proxy) and the next Http.Handler, whenever a request is fired through the Http class.

Decorator

Provide

Example

Simple Proxy intercepting file: requests:

import { type Http, Provider, type Proxy, Target } from '@sgrud/core';
import { type Observable, of } from 'rxjs';
import { file } from './file';

⁠@Target()
export class FileProxy
extends Provider<typeof Proxy>('sgrud.core.Proxy') {

public override handle(
request: Http.Request,
handler: Http.Handler
): Observable<Http.Response> {
if (request.url.startsWith('file:')) {
return of<Http.Response>(file);
}

return handler.handle(request);
}

}

See

Http

Hierarchy (view full)

Constructors

Properties

Methods

Constructors

Properties

[provide]: "sgrud.core.Proxy" = 'sgrud.core.Proxy'

Magic string by which this class is provided.

Methods

Generated using TypeDoc