1
0
Fork 0
mirror of https://github.com/openstf/stf synced 2025-10-04 10:19:30 +02:00

Too much overlap in storage plugin URLs for meaningful loadbalancing and config simplicity. Make poorxy emulate the real situation and change related URLs.

This commit is contained in:
Simo Kinnunen 2015-01-07 14:04:36 +09:00
parent 7c16c40dae
commit 8b9e5d58c9
8 changed files with 70 additions and 57 deletions

View file

@ -30,7 +30,7 @@ module.exports = function(options) {
log.info('Cleaning up inactive resource "%s"', id)
})
app.post('/s/api/v1/:type/download', function(req, res) {
app.post('/s/download/:plugin', function(req, res) {
requtil.validate(req, function() {
req.checkBody('url').notEmpty()
})
@ -46,17 +46,18 @@ module.exports = function(options) {
}
})
.then(function(file) {
var plugin = req.params.plugin
res.status(201)
.json({
success: true
, resource: {
date: new Date()
, type: req.params.type
, plugin: plugin
, id: file.id
, name: file.name
, href: util.format(
'/s/api/v1/%s/%s%s'
, req.params.type
'/s/%s/%s%s'
, plugin
, file.id
, file.name
? util.format('/%s', path.basename(file.name))
@ -83,7 +84,7 @@ module.exports = function(options) {
})
})
app.post('/s/api/v1/:type', function(req, res) {
app.post('/s/upload/:plugin', function(req, res) {
var form = new formidable.IncomingForm()
Promise.promisify(form.parse, form)(req)
.spread(function(fields, files) {
@ -104,14 +105,15 @@ module.exports = function(options) {
, resources: (function() {
var mapped = Object.create(null)
storedFiles.forEach(function(file) {
var plugin = req.params.plugin
mapped[file.field] = {
date: new Date()
, type: req.params.type
, plugin: plugin
, id: file.id
, name: file.name
, href: util.format(
'/s/api/v1/%s/%s%s'
, req.params.type
'/s/%s/%s%s'
, plugin
, file.id
, file.name
? util.format('/%s', path.basename(file.name))
@ -133,7 +135,7 @@ module.exports = function(options) {
})
})
app.get('/s/api/v1/:type/:id/*', function(req, res) {
app.get('/s/blob/:id/:name', function(req, res) {
var file = storage.retrieve(req.params.id)
if (file) {
res.set('Content-Type', file.type)