mirror of
https://github.com/seejohnrun/haste-server.git
synced 2024-11-01 03:21:21 +00:00
Clean up the router
This commit is contained in:
parent
a7aec372d5
commit
12aa622c2d
2 changed files with 5 additions and 4 deletions
1
TODO.md
1
TODO.md
|
@ -8,7 +8,6 @@
|
||||||
* Better about page text
|
* Better about page text
|
||||||
* test new interface in browsers
|
* test new interface in browsers
|
||||||
* compress assets
|
* compress assets
|
||||||
* look for a better way to do router
|
|
||||||
|
|
||||||
|
|
||||||
# shared version only
|
# shared version only
|
||||||
|
|
|
@ -61,6 +61,7 @@ var documentHandler = new DocumentHandler({
|
||||||
|
|
||||||
// Set the server up with a static cache
|
// Set the server up with a static cache
|
||||||
connect.createServer(
|
connect.createServer(
|
||||||
|
// First look for api calls
|
||||||
connect.router(function(app) {
|
connect.router(function(app) {
|
||||||
// add documents
|
// add documents
|
||||||
app.post('/documents', function(request, response, next) {
|
app.post('/documents', function(request, response, next) {
|
||||||
|
@ -74,14 +75,15 @@ connect.createServer(
|
||||||
// Otherwise, static
|
// Otherwise, static
|
||||||
connect.staticCache(),
|
connect.staticCache(),
|
||||||
connect.static(__dirname + '/static', { maxAge: config.staticMaxAge }),
|
connect.static(__dirname + '/static', { maxAge: config.staticMaxAge }),
|
||||||
// Then we can loop back - and change these into '/' TODO
|
// Then we can loop back - and everything else should be a token,
|
||||||
|
// so route it back to /index.html
|
||||||
connect.router(function(app) {
|
connect.router(function(app) {
|
||||||
app.get('/:id', function(request, response, next) {
|
app.get('/:id', function(request, response, next) {
|
||||||
request.url = request.originalUrl = '/';
|
request.url = request.originalUrl = '/index.html';
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
}),
|
}),
|
||||||
// Static
|
// And then let static take over
|
||||||
connect.staticCache(),
|
connect.staticCache(),
|
||||||
connect.static(__dirname + '/static', { maxAge: config.staticMaxAge })
|
connect.static(__dirname + '/static', { maxAge: config.staticMaxAge })
|
||||||
).listen(config.port, config.host);
|
).listen(config.port, config.host);
|
||||||
|
|
Loading…
Reference in a new issue