@ima/core
Version:
IMA.js framework for isomorphic javascript application
118 lines (117 loc) • 4.38 kB
JavaScript
/**
* The {@link HttpAgent} defines unifying API for sending HTTP requests at
* both client-side and server-side.
*/ export class HttpAgent {
/**
* Sends an HTTP GET request to the specified URL, sending the provided
* data as query parameters.
*
* @param url The URL to which the request should be made.
* @param data The data to send
* to the server as query parameters.
* @param options Optional request options.
* @return A promise that resolves to the
* response.
*/ get(url, data, options) {
return Promise.reject();
}
/**
* Sends an HTTP POST request to the specified URL, sending the provided
* data as the request body. If an object is provided as the request data,
* the data will be JSON-encoded. Sending other primitive non-string values
* as the request body is not supported.
*
* @param url The URL to which the request should be made.
* @param data The data to send to the server
* as the request body.
* @param options Optional request options.
* @return A promise that resolves to the
* response.
*/ post(url, data, options) {
return Promise.reject();
}
/**
* Sends an HTTP PUT request to the specified URL, sending the provided
* data as the request body. If an object is provided as the request data,
* the data will be JSON-encoded. Sending other primitive non-string values
* as the request body is not supported.
*
* @param url The URL to which the request should be made.
* @param data The data to send to the server
* as the request body.
* @param options Optional request options.
* @return A promise that resolves to the
* response.
*/ put(url, data, options) {
return Promise.reject();
}
/**
* Sends an HTTP PATCH request to the specified URL, sending the provided
* data as the request body. If an object is provided as the request data,
* the data will be JSON-encoded. Sending other primitive non-string values
* as the request body is not supported.
*
* @param url The URL to which the request should be made.
* @param data The data to send to the server
* as the request body.
* @param options Optional request options.
* @return A promise that resolves to the
* response.
*/ patch(url, data, options) {
return Promise.reject();
}
/**
* Sends an HTTP DELETE request to the specified URL, sending the provided
* data as the request body. If an object is provided as the request data,
* the data will be JSON-encoded. Sending other primitive non-string values
* as the request body is not supported.
*
* @param url The URL to which the request should be made.
* @param data The data to send to the server
* as the request body.
* @param options Optional request options.
* @return A promise that resolves to the
* response.
*/ delete(url, data, options) {
return Promise.reject();
}
/**
* Generates a cache key to use for identifying a request to the specified
* URL using the specified HTTP method, submitting the provided data.
*
* @param method The HTTP method used by the request.
* @param url The URL to which the request is sent.
* @param data The data associated with the
* request. These can be either the query parameters or request body
* data.
* @return The key to use for identifying such a request in the
* cache.
*/ getCacheKey(method, url, data) {
return '';
}
/**
* Method invalidate cache for given params
*/ invalidateCache(method, url, data) {
return;
}
/**
* Sets the specified header to be sent with every subsequent HTTP request,
* unless explicitly overridden by request options.
*
* @param header The name of the header.
* @param value The header value. To provide multiple values,
* separate them with commas
* (see http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.2).
* @return This HTTP agent.
*/ setDefaultHeader(header, value) {
return this;
}
/**
* Clears all configured default headers.
*
* @return This HTTP agent.
*/ clearDefaultHeaders() {
return this;
}
}
//# sourceMappingURL=HttpAgent.js.map