]> gerrit.simantics Code Review - simantics/district.git/blob - get.js
ab0eae10f012181fef2e17246bb869d5e7fd5862
[simantics/district.git] / get.js
1 module.exports = get
2
3 var assert = require('assert')
4 var url = require('url')
5
6 /*
7  * This is meant to be overridden in specific implementations if you
8  * want specialized behavior for metadata (i.e. caching).
9  */
10 function get (uri, params, cb) {
11   assert(typeof uri === 'string', 'must pass registry URI to get')
12   assert(params && typeof params === 'object', 'must pass params to get')
13   assert(typeof cb === 'function', 'must pass callback to get')
14
15   var parsed = url.parse(uri)
16   assert(
17     parsed.protocol === 'http:' || parsed.protocol === 'https:',
18     'must have a URL that starts with http: or https:'
19   )
20
21   this.request(uri, params, cb)
22 }