A basic HTTP protocol for vector layers. Create a new instance with the ALKMaps.Protocol.HTTP constructor.
ALKMaps. | A basic HTTP protocol for vector layers. |
Properties | |
url | {String} Service URL, read-only, set through the options passed to constructor. |
headers | {Object} HTTP request headers, read-only, set through the options passed to the constructor, Example: {‘Content-Type’: ‘plain/text’} |
params | {Object} Parameters of GET requests, read-only, set through the options passed to the constructor, Example: {‘bbox’: ‘5,5,5,5’} |
callback | {Object} Function to be called when the read, create, update, delete or commit operation completes, read-only, set through the options passed to the constructor. |
scope | {Object} Callback execution scope, read-only, set through the options passed to the constructor. |
readWithPOST | {Boolean} true if read operations are done with POST requests instead of GET, defaults to false. |
updateWithPOST | {Boolean} true if update operations are done with POST requests defaults to false. |
deleteWithPOST | {Boolean} true if delete operations are done with POST requests defaults to false. |
wildcarded. | {Boolean} If true percent signs are added around values read from LIKE filters, for example if the protocol read method is passed a LIKE filter whose property is “foo” and whose value is “bar” the string “foo__ilike=%bar%” will be sent in the query string; defaults to false. |
srsInBBOX | {Boolean} Include the SRS identifier in BBOX query string parameter. |
Constructor | |
ALKMaps. | A class for giving layers generic HTTP protocol. |
Functions | |
destroy | Clean up the protocol. |
filterToParams | Optional method to translate an ALKMaps.Filter object into an object that can be serialized as request query string provided. |
read | Construct a request for reading new features. |
handleRead | Individual callbacks are created for read, create and update, should a subclass need to override each one separately. |
create | Construct a request for writing newly created features. |
handleCreate | Called the the request issued by create is complete. |
update | Construct a request updating modified feature. |
handleUpdate | Called the the request issued by update is complete. |
delete | Construct a request deleting a removed feature. |
handleDelete | Called the the request issued by delete is complete. |
handleResponse | Called by CRUD specific handlers. |
parseFeatures | Read HTTP response body and return features. |
commit | Iterate over each feature and take action based on the feature state. |
abort | Abort an ongoing request, the response object passed to this method must come from this HTTP protocol (as a result of a create, read, update, delete or commit operation). |
callUserCallback | This method is used from within the commit method each time an an HTTP response is received from the server, it is responsible for calling the user-supplied callbacks. |
A class for giving layers generic HTTP protocol.
options | {Object} Optional object whose properties will be set on the instance. |
url | {String} |
headers | {Object} |
params | {Object} URL parameters for GET requests |
format | {ALKMaps.Format} |
callback | {Function} |
scope | {Object} |
Optional method to translate an ALKMaps.Filter object into an object that can be serialized as request query string provided. If a custom method is not provided, the filter will be serialized using the ALKMaps.Format.QueryStringFilter class.
filter | {ALKMaps.Filter} filter to convert. |
params | {Object} The parameters object. |
{Object} The resulting parameters object.
read: function( options )
Construct a request for reading new features.
options | {Object} Optional object for configuring the request. This object is modified and should not be reused. |
url | {String} Url for the request. |
params | {Object} Parameters to get serialized as a query string. |
headers | {Object} Headers to be set on the request. |
filter | {ALKMaps.Filter} Filter to get serialized as a query string. |
readWithPOST | {Boolean} If the request should be done with POST. |
{ALKMaps.Protocol.Response} A response object, whose “priv” property references the HTTP request, this object is also passed to the callback function when the request completes, its “features” property is then populated with the features received from the server.
handleRead: function( resp, options )
Individual callbacks are created for read, create and update, should a subclass need to override each one separately.
resp | {ALKMaps.Protocol.Response} The response object to pass to the user callback. |
options | {Object} The user options passed to the read call. |
create: function( features, options )
Construct a request for writing newly created features.
features | {Array({ALKMaps.Feature.Vector})} or {ALKMaps.Feature.Vector} |
options | {Object} Optional object for configuring the request. This object is modified and should not be reused. |
{ALKMaps.Protocol.Response} An ALKMaps.Protocol.Response object, whose “priv” property references the HTTP request, this object is also passed to the callback function when the request completes, its “features” property is then populated with the the features received from the server.
handleCreate: function( resp, options )
Called the the request issued by create is complete. May be overridden by subclasses.
resp | {ALKMaps.Protocol.Response} The response object to pass to any user callback. |
options | {Object} The user options passed to the create call. |
update: function( feature, options )
Construct a request updating modified feature.
feature | {ALKMaps.Feature.Vector} |
options | {Object} Optional object for configuring the request. This object is modified and should not be reused. |
{ALKMaps.Protocol.Response} An ALKMaps.Protocol.Response object, whose “priv” property references the HTTP request, this object is also passed to the callback function when the request completes, its “features” property is then populated with the the feature received from the server.
handleUpdate: function( resp, options )
Called the the request issued by update is complete. May be overridden by subclasses.
resp | {ALKMaps.Protocol.Response} The response object to pass to any user callback. |
options | {Object} The user options passed to the update call. |
"delete": function( feature, options )
Construct a request deleting a removed feature.
feature | {ALKMaps.Feature.Vector} |
options | {Object} Optional object for configuring the request. This object is modified and should not be reused. |
{ALKMaps.Protocol.Response} An ALKMaps.Protocol.Response object, whose “priv” property references the HTTP request, this object is also passed to the callback function when the request completes.
handleDelete: function( resp, options )
Called the the request issued by delete is complete. May be overridden by subclasses.
resp | {ALKMaps.Protocol.Response} The response object to pass to any user callback. |
options | {Object} The user options passed to the delete call. |
handleResponse: function( resp, options )
Called by CRUD specific handlers.
resp | {ALKMaps.Protocol.Response} The response object to pass to any user callback. |
options | {Object} The user options passed to the create, read, update, or delete call. |
parseFeatures: function( request )
Read HTTP response body and return features.
request | {XMLHttpRequest} The request object |
{Array({ALKMaps.Feature.Vector})} or {ALKMaps.Feature.Vector} Array of features or a single feature.
commit: function( features, options )
Iterate over each feature and take action based on the feature state. Possible actions are create, update and delete.
features | {Array({ALKMaps.Feature.Vector})} |
options | {Object} Optional object for setting up intermediate commit callbacks. |
create | {Object} Optional object to be passed to the create method. |
update | {Object} Optional object to be passed to the update method. |
delete | {Object} Optional object to be passed to the delete method. |
callback | {Function} Optional function to be called when the commit is complete. |
scope | {Object} Optional object to be set as the scope of the callback. |
{Array(ALKMaps.Protocol.Response)} An array of response objects, one per request made to the server, each object’s “priv” property references the corresponding HTTP request.
abort: function( response )
Abort an ongoing request, the response object passed to this method must come from this HTTP protocol (as a result of a create, read, update, delete or commit operation).
response | {ALKMaps.Protocol.Response} |
callUserCallback: function( resp, options )
This method is used from within the commit method each time an an HTTP response is received from the server, it is responsible for calling the user-supplied callbacks.
resp | {ALKMaps.Protocol.Response} |
options | {Object} The map of options passed to the commit call. |
Construct a request for reading new features.
read: function( options )
Construct a request for writing newly created features.
create: function( features, options )
Construct a request updating modified feature.
update: function( feature, options )
Construct a request deleting a removed feature.
"delete": function( feature, options )
Iterate over each feature and take action based on the feature state.
commit: function( features, options )
Clean up the protocol.
destroy: function()
Individual callbacks are created for read, create and update, should a subclass need to override each one separately.
handleRead: function( resp, options )
Called the the request issued by create is complete.
handleCreate: function( resp, options )
Called the the request issued by update is complete.
handleUpdate: function( resp, options )
Called the the request issued by delete is complete.
handleDelete: function( resp, options )
Called by CRUD specific handlers.
handleResponse: function( resp, options )
Read HTTP response body and return features.
parseFeatures: function( request )
Abort an ongoing request, the response object passed to this method must come from this HTTP protocol (as a result of a create, read, update, delete or commit operation).
abort: function( response )
This method is used from within the commit method each time an an HTTP response is received from the server, it is responsible for calling the user-supplied callbacks.
callUserCallback: function( resp, options )