Add /:id/raw
This commit is contained in:
parent
e067323714
commit
a541630848
16
server.js
16
server.js
|
@ -1,3 +1,4 @@
|
||||||
|
// vim: set ts=2 sw=2 sts=2 et:
|
||||||
var http = require('http');
|
var http = require('http');
|
||||||
var fs = require('fs');
|
var fs = require('fs');
|
||||||
|
|
||||||
|
@ -106,14 +107,17 @@ if (config.rateLimits) {
|
||||||
app.use(connect_rate_limit(config.rateLimits));
|
app.use(connect_rate_limit(config.rateLimits));
|
||||||
}
|
}
|
||||||
|
|
||||||
// first look at API calls
|
function raw(request, response) {
|
||||||
app.use(route(function(router) {
|
|
||||||
// get raw documents - support getting with extension
|
|
||||||
router.get('/raw/:id', function(request, response) {
|
|
||||||
var key = request.params.id.split('.')[0];
|
var key = request.params.id.split('.')[0];
|
||||||
var skipExpire = !!config.documents[key];
|
var skipExpire = !!config.documents[key];
|
||||||
return documentHandler.handleRawGet(key, response, skipExpire);
|
return documentHandler.handleRawGet(key, response, skipExpire);
|
||||||
});
|
}
|
||||||
|
|
||||||
|
// first look at API calls
|
||||||
|
app.use(route(function(router) {
|
||||||
|
// get raw documents - support getting with extension
|
||||||
|
router.get('/raw/:id', raw);
|
||||||
|
router.get('/:id/raw', raw);
|
||||||
// add documents
|
// add documents
|
||||||
router.post('/documents', function(request, response) {
|
router.post('/documents', function(request, response) {
|
||||||
return documentHandler.handlePost(request, response);
|
return documentHandler.handlePost(request, response);
|
||||||
|
@ -137,7 +141,7 @@ app.use(connect_st({
|
||||||
// Then we can loop back - and everything else should be a token,
|
// Then we can loop back - and everything else should be a token,
|
||||||
// so route it back to /
|
// so route it back to /
|
||||||
app.use(route(function(router) {
|
app.use(route(function(router) {
|
||||||
router.get('/:id', function(request, response, next) {
|
router.get('/:id', function(request, _response, next) {
|
||||||
request.sturl = '/';
|
request.sturl = '/';
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
Loading…
Reference in New Issue