Middleware reqContent

maiah edited this page Oct 3, 2012 · 1 revision
Clone this wiki locally


Use this middleware if you want to parse request POST content. Once used, the content will be available thru Request's dataMap field.

Sample usage


main() {

  route('GET', '/login', (req, res) {
        <!DOCTYPE html>
        <form action="/login" method="POST">
        <input type="text" name="username" placeholder="Username" /><br />
        <input type="password" name="password" placeholder="Password" /><br />
        <input type="submit" value="Login" />

  route('POST', '/login', (req, res) {
    res.write("Hello ${req.dataMap['username']}");

  print('Listening on port 7000');

Run this program and access the server path http://localhost:7000/login and type maiah for username and 12345 for password and you will get the response below.

Hello maiah