@@ -36,3 +36,112 @@ The session storage works just like the local storage engine with the important
3636
3737## Remote Storage
3838
39+ For remote storage, your configuration in ` options.js ` can be set as follow.
40+
41+ ``` javascript
42+ ' Storage' : {
43+ ' Adapter' : ' RemoteStorage' ,
44+ ' Store' : ' ' ,
45+ ' Endpoint' : ' https://foobar.com/gameSave'
46+ }
47+ ```
48+
49+ Or you may add a store name:
50+
51+ ``` javascript
52+ ' Storage' : {
53+ ' Adapter' : ' RemoteStorage' ,
54+ ' Store' : ' MyGame' ,
55+ ' Endpoint' : ' https://foobar.com/gameSave/'
56+ }
57+ ```
58+
59+ The storage engine concats the ` Store ` and ` Endpoint ` values as the actual RESTful API ** endpoint url** to use:
60+
61+ ```
62+ https://foobar.com/gameSave/MyGame
63+ ```
64+
65+ ### Implementing the Remote Storage
66+
67+ The storage mimic that of a localStorage, which is simple JSON object storage.
68+
69+ The ** endpoint url** should implement the below API interface:
70+
71+ ---
72+
73+ ``` http
74+ GET [endpoint url]/
75+ ```
76+
77+ {% hint style="info" %}
78+ Normally, retrieves all the values in the space in a key-value JSON object. If previous storage does not exist, return an empty JSON object: ` {} ` .
79+
80+ In keys-listing mode, return all keys stored in the space as a JSON array.
81+ {% endhint %}
82+
83+ ** Parameters**
84+
85+ | Name | Description |
86+ | ---- | ----------- |
87+ | keys | Boolean. If set to ` true ` , will switch to keys-listing mode. |
88+
89+ ---
90+
91+ ``` http
92+ DELETE [endpoint url]/
93+ ```
94+
95+ {% hint style="info" %}
96+ Clear the entire storage object.
97+
98+ Equivlant to
99+ ``` javascript
100+ localStorage .clear ();
101+ ```
102+ {% endhint %}
103+
104+ ---
105+
106+ ``` http
107+ GET [endpoint url]/{key}
108+ ```
109+
110+ {% hint style="info" %}
111+ Return the value of the key in the storage object.
112+
113+ Equivlant to
114+ ``` javascript
115+ localStorage .getItem (key);
116+ ```
117+ {% endhint %}
118+
119+ ---
120+
121+ ``` http
122+ POST [endpoint url]/{key}
123+ ```
124+
125+ {% hint style="info" %}
126+ Store the value in the storage object under the key.
127+
128+ Equivlant to
129+ ``` javascript
130+ localStorage .setItem (key, value);
131+ ```
132+ {% endhint %}
133+
134+ ---
135+
136+ ``` http
137+ DELETE [endpoint url]/{key}
138+ ```
139+
140+ {% hint style="info" %}
141+ Return the value of the key in the storage object.
142+
143+ Equivlant to
144+ ``` javascript
145+ localStorage .removeItem (key);
146+ ````
147+ {% endhint % }
0 commit comments