Skip to content
module@warp-drive/utilities/handlers

Class AutoCompress sincev5.5.0

Defined in: -private/handlers/auto-compress.ts:186

A request handler that automatically compresses the request body if the request body is a string, array buffer, blob, or form data.

This uses the CompressionStream API

The compression format as well as the kinds of data to compress can be configured using the format and constraints options.

diff
+import { AutoCompress } from '@ember-data/request-utils/handlers';
import Fetch from '@ember-data/request/fetch';
import RequestManager from '@ember-data/request';
import Store from '@ember-data/store';

class AppStore extends Store {
  requestManager = new RequestManager()
    .use([
+       new AutoCompress(),
       Fetch
    ]);
}

Implements

  • Handler

Constructors

Constructor

ts
new AutoCompress(options?): AutoCompress;

Defined in: -private/handlers/auto-compress.ts:198

Parameters

options?

CompressionOptions = {}

Returns

AutoCompress

Methods

request()

ts
request<T>(__namedParameters, next): 
  | Promise<T>
| Future<T>;

Defined in: -private/handlers/auto-compress.ts:208

Method to implement to handle requests. Receives the request context and a nextFn to call to pass-along the request to other handlers.

Type Parameters

T

T

Parameters

__namedParameters

RequestContext

next

NextFn<T>

Returns

| Promise<T> | Future<T>

Implementation of

ts
Handler.request

Properties

options

ts
options: Required<CompressionOptions> & object;

Defined in: -private/handlers/auto-compress.ts:191

The resolved options this handler was configured with, with all defaults (including constraints defaults) applied.

Type Declaration

constraints
ts
constraints: Required<Constraints>;

The resolved size constraints used to decide whether to compress a given request body.

Released under the MIT License.