add ext: protocol

This commit is contained in:
Paul Frazee
2015-06-24 21:23:27 -05:00
parent f3421c4bba
commit fe030cb0e0
3 changed files with 20 additions and 1 deletions

14
app/lib/ext-protocol.js Normal file
View File

@@ -0,0 +1,14 @@
var protocol = require('protocol')
var path = require('path')
var toPath = require('multiblob/util').toPath
module.exports = function (config) {
var dir = path.join(config.path, 'blobs')
return function (request) {
var id = request.url.split(':')[1]
if (request.method == 'GET' && id) {
console.log('loading', id, toPath(dir, id))
return new protocol.RequestFileJob(toPath(dir, id))
}
}
}