WireClient Interface
This file exposes a get/put/delete interface on top of XMLHttpRequest. It requires to be configured with parameters about the remotestorage server to connect to. Each instance of WireClient is always associated with a single remotestorage server and access token.
Usually the WireClient instance can be accessed via `remoteStorage.remote`.
This is the get/put/delete interface
- #get() takes a path and optionally a ifNoneMatch option carrying a version string to check. It returns a promise that will be fulfilled with the HTTP response status, the response body, the MIME type as returned in the ‘Content-Type’ header and the current revision, as returned in the ‘ETag’ header.
- #put() takes a path, the request body and a content type string. It also accepts the ifMatch and ifNoneMatch options, that map to the If-Match and If-None-Match headers respectively. See the remotestorage-01 specification for details on handling these headers. It returns a promise, fulfilled with the same values as the one for #get().
- #delete() takes a path and the ifMatch option as well. It returns a promise fulfilled with the same values as the one for #get().
In addition to this, the WireClient has some compatibility features to work with remotestorage 2012.04 compatible storages. For example it will cache revisions from folder listings in-memory and return them accordingly as the “revision” parameter in response to #get() requests. Similarly it will return 404 when it receives an empty folder listing, to mimic remotestorage-01 behavior. Note that it is not always possible to know the revision beforehand, hence it may be undefined at times (especially for caching-roots).
Summary
RemoteStorage.WireClient | WireClient Interface |
Events | |
change | Never fired for some reason # TODO create issue and fix or remove |
connected | Fired when the wireclient connect method realizes that it is in possession of a token and href |
Properties | |
token | Holds the bearer token of this WireClient, as obtained in the OAuth dance |
href | Holds the server’s base URL, as obtained in the Webfinger discovery |
storageApi | Holds the spec version the server claims to be compatible with |
Functions | |
configure | Sets the userAddress, href, storageApi, token, and properties of a remote store. |