문제

have known node.js and express several days ago. I feel they are really cool, however, lacking of something.

I looked the official site, but it just point to Connect's API. But I can't find a document which teach me how to use a simple function such as expressHTTPServer.get().

Of course I read the nodejs's API, but the Express and Connect seems to extend them very much.

For example, in Express official site:

app = express.createServer();
app.get('/user/:id', function(req, res, next){
   loadUser(req.params.id, function(err, user){
     if (err)
       return next(err);
    res.send('Viewing user of csser.com ' + user.name);  }
   );
});

But sadly, no API document talk me there is expressHTTPServer.get and what it's callback arguments are.

I like to read examples, but I really need an API to learn a new language/library/framework, anyone helps?

도움이 되었습니까?

해결책

Here are the official docs: http://expressjs.com/guide.html

Also, the source can answer a lot of your questions: https://github.com/visionmedia/express

다른 팁

If I understand your question correctly, you want to get to know the API of the req and res parameters passed to your callback, right?

Have a look at http.ServerRequest and http.ServerResponse

Express itself uses Connect which uses the standard Node.js HTTP API. The arguments passed to your callback are monkey patched instances of the described objects.

The Argument "next" is a function you can call if you wish that the request gets handled by another middleware module. If you want to handle the request within your handler, this doesn't need to bother you.

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top