Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Added support for echoecho in yogi serve

  • Loading branch information...
commit 5ee267d883f1260809019391d88a2168da3311be 1 parent f4b560b
@davglass davglass authored
Showing with 20 additions and 3 deletions.
  1. +19 −3 lib/cmds/serve.js
  2. +1 −0  package.json
View
22 lib/cmds/serve.js
@@ -9,6 +9,7 @@ var util = require('../util'),
fs = require('fs'),
git = require('../git'),
path = require('path'),
+ echoecho = require('echoecho'),
request = require('request'),
urlParse = require('url').parse,
spawn = require('child_process').spawn,
@@ -94,6 +95,7 @@ mods = {
},
tests: function() {
var self = this,
+ handler,
gbase = path.join(git.findRoot(process.cwd()), '../'),
base = (util.isYUI() ? path.join(this.module.dir, this.module.name) : this.module.dir),
testDir = path.join(base, 'tests/unit');
@@ -103,7 +105,12 @@ mods = {
res.redirect('/');
});
- this.app.get('/tests/'+'*', function(req, res) {
+
+ echoecho.paths([
+ '/tests/unit/index.html'
+ ]);
+
+ handler = function(req, res) {
var file = path.join(base, 'tests', req.params[0]);
if (util.exists(file)) {
fs.readFile(file, 'utf8', function(err, data) {
@@ -115,9 +122,18 @@ mods = {
}
});
} else {
- res.send('Not Found', 404);
+ if (echoecho.handle(req)) {
+ echoecho.serve(req, res);
+ } else {
+ res.send('YOGI Not Found', 404);
+ }
}
- });
+ };
+
+ this.app.get('/tests/'+'*', handler);
+ this.app.post('/tests/'+'*', handler);
+ this.app.put('/tests/'+'*', handler);
+ this.app.delete('/tests/'+'*', handler);
this.app.get('/build/' + '*', function(req, res) {
var file = path.join(gbase, 'build', req.params[0]);
View
1  package.json
@@ -24,6 +24,7 @@
"yui-lint": "*",
"shifter": ">=0.0.10",
"portfinder": "*",
+ "echoecho": "*",
"editor": "https://github.com/dominictarr/node-editor/tarball/master"
},
"scripts": {
Please sign in to comment.
Something went wrong with that request. Please try again.