koajs / ejs

a koa view render middleware, support all feature of ejs

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Always get a 204 (no content) response no matter what settings I use

juanmac opened this issue · comments

currently i have this on the server:

var path = require('path');
var koa = require('koa');
var render = require('koa-ejs');

var app = koa();

render(app,{
  root: path.join(__dirname, "views"),
  layout:false
});

app.use(function*(){
  this.body = yield this.render("home");
});

app.listen(3000);
console.log("listen at localhost:3000");

.. and as "home" (views/home.html)

<html>
  <head>
    <title>koa ejs</title>
  </head>

  <body>
    hello koa-ejs
  </body>

</html>

when a run curl localhost:3000 -v I get:

* Rebuilt URL to: localhost:3000/
* Hostname was NOT found in DNS cache
*   Trying 127.0.0.1...
* Connected to localhost (127.0.0.1) port 3000 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.35.0
> Host: localhost:3000
> Accept: */*
> 
< HTTP/1.1 204 No Content
< X-Powered-By: koa
< Date: Wed, 15 Oct 2014 03:08:15 GMT
< Connection: keep-alive
< 
* Connection #0 to host localhost left intact

Am I doing something wrong? I'm using this dependencies:

"dependencies": {
    "koa": "^0.12.2",
    "koa-ejs": "^1.1.2"
  }

this.render set this.body already. try

app.use(function*(){
  yield this.render("home");
});

sorry about that, closing now.. and thanks!