@opra/client
Version:
Opra Client package
57 lines (56 loc) • 1.83 kB
TypeScript
import type { ApiDocument } from '@opra/common';
import { Observable } from 'rxjs';
import type { HttpEvent } from './interfaces/http-event.js';
import type { HttpHandler } from './interfaces/http-handler.js';
import type { HttpInterceptor } from './interfaces/http-interceptor.js';
/**
* Base class for HTTP backends.
*
* @class HttpBackend
*/
export declare abstract class HttpBackend implements HttpHandler {
/** The API document associated with this backend */
document?: ApiDocument;
/** The base URL of the service */
readonly serviceUrl: string;
/** List of HTTP interceptors */
interceptors?: HttpInterceptor<any>[];
/**
* Creates a new instance of HttpBackend.
*
* @param serviceUrl The base URL of the service.
* @param options Configuration options.
* @protected
*/
protected constructor(serviceUrl: string, options?: HttpBackend.Options);
/**
* Handles the request and returns an observable of {@link HttpEvent}.
*
* @param init The request initialization parameters.
* @returns An observable of HttpEvent.
*/
abstract handle(init: HttpBackend.RequestInit): Observable<HttpEvent>;
}
/**
* Namespace for {@link HttpBackend} related types and interfaces.
*
* @namespace HttpBackend
*/
export declare namespace HttpBackend {
/** Configuration options for HttpBackend */
interface Options {
/** The API document associated with this backend */
document?: ApiDocument;
}
/** Request initialization parameters for HttpBackend */
interface RequestInit {
/** HTTP method (GET, POST, etc.) */
method: string;
/** The target URL */
url: string | URL;
/** HTTP headers */
headers?: Headers;
/** Request body */
body?: any;
}
}