aboutsummaryrefslogtreecommitdiff
path: root/lib/serve.js
diff options
context:
space:
mode:
Diffstat (limited to 'lib/serve.js')
-rw-r--r--lib/serve.js31
1 files changed, 30 insertions, 1 deletions
diff --git a/lib/serve.js b/lib/serve.js
index 2eba468..92d6065 100644
--- a/lib/serve.js
+++ b/lib/serve.js
@@ -378,6 +378,7 @@ Serve.prototype.path = function (url) {
case '/npm-registry': return this.npmRegistry(m[2])
case '/markdown': return this.markdown(m[2])
case '/edit-diff': return this.editDiff(m[2])
+ case '/shard': return this.shard(m[2])
case '/zip': return this.zip(m[2])
case '/web': return this.web(m[2])
}
@@ -3478,7 +3479,11 @@ Serve.prototype.editDiff = function (url) {
try {
id = decodeURIComponent(url.substr(1))
} catch(err) {
- return ph('div', u.renderError(err).outerHTML)
+ return pull(
+ pull.once(u.renderError(err).outerHTML),
+ self.wrapPage('diff: ' + id),
+ self.respondSink(400)
+ )
}
return pull(
ph('section', {}, [
@@ -3547,3 +3552,27 @@ Serve.prototype.postEditDiffTable = function (oldMsg, newMsg) {
])
)
}
+
+Serve.prototype.shard = function (url) {
+ var self = this
+ var id
+ try {
+ id = decodeURIComponent(url.substr(1))
+ } catch(err) {
+ return onError(err)
+ }
+ function onError(err) {
+ pull(
+ pull.once(u.renderError(err).outerHTML),
+ self.wrapPage('shard: ' + id),
+ self.respondSink(400)
+ )
+ }
+ self.app.getShard(id, function (err, shard) {
+ if (err) return onError(err)
+ pull(
+ pull.once(shard),
+ self.respondSink(200, {'Content-Type': 'text/plain'})
+ )
+ })
+}