TESSA Web API
    Preparing search index...

    Module Application.Http

    example
    const client = new HttpClient();
    const data = await client.get('https://my-api.com/data').json();
    example
    const client = new HttpClient();
    const request = {
    id: 1,
    name: 'test'
    };
    await client.post('https://my-api.com/data', { json: request }).execute();
    example
    @injectable()
    class MyClass {
    constructor(@inject(IHttpClient$) private readonly _client: IHttpClient) {}
    }
    example
    // myApiInterceptor.ts

    @extension({ name: 'MyApiInterceptor' })
    export class MyApiInterceptor extends HttpInterceptor<ApiClientOptions> {
    override async enhanceOptions(
    context: HttpInterceptorOptionsContext<ApiClientOptions>
    ): Promise<void> {
    const { options } = context;
    options.baseURL = 'https://my-api.com';
    }
    }

    // registrator.ts

    extensionContainer.registerExtension({
    extension: MyApiInterceptor,
    when: whenClientTypeIs(IApiClient$)
    });
    example
    const data = await client
    .get('https://my-api.com/data', {
    hooks: [
    {
    beforeRequest: async ctx => {
    ctx.request.headers.set('my-header', 'my-header-value');
    }
    }
    ]
    })
    .typedJson();
    example
    const context = new HttpHooksContext([
    {
    beforeRequest: async ctx => {
    ctx.request.headers.set('my-header', 'my-header-value');
    }
    }
    ]);
    await HttpHooksContext.create(context).run(async () => await someLogicWithHttpRequestInside());
    example
    container
    .bind(IHttpInterceptorHooksProvider$)
    .toFunction(() => [
    {
    beforeRequest: async ctx => {
    ctx.request.headers.set('my-header', 'my-header-value');
    }
    }
    ])
    .whenAnyAncestorIs(IOperationService$);
    example
    const context = new CancellationContext();
    CancellationContext.create(context).run(() => await someLogicWithHttpRequestInside());
    context.cancel();

    Namespaces

    HttpHelper
    HttpRequestHeaders

    Classes

    ApiClient
    HttpClient
    HttpError
    HttpExecutor
    HttpHooksContext
    HttpInterceptor
    HttpInterceptorContext
    HttpInvalidRequestError
    HttpNoContentError
    HttpTimeoutError

    Interfaces

    ApiClientOptions
    HttpInterceptorErrorContext
    HttpInterceptorOptionsContext
    HttpInterceptorRequestContext
    HttpInterceptorResponseContext
    HttpOptions
    HttpResponse
    IApiClient
    IHttpClient
    IHttpExecutor
    IHttpInterceptorHooksProvider

    Type Aliases

    HttpInput
    HttpInterceptorHooks
    HttpSearchParams
    WithHeadersInit

    Variables - Other

    HttpRegistrator

    Variables - injects

    IApiClient$
    IHttpClient$
    IHttpInterceptorHooksProvider$

    Functions

    whenClientTypeIs
    whenClientTypeOnlyIs
    whenHttpUrlIs