-
Notifications
You must be signed in to change notification settings - Fork 9
Middleware reqContent
maiah edited this page Oct 3, 2012
·
1 revision
Use this middleware if you want to parse request POST content. Once used, the content will be available thru Request's dataMap field.
#import('package:synth/synth.dart');
main() {
use(reqContent);
route('GET', '/login', (req, res) {
res.write(
'''
<!DOCTYPE html>
<html>
<body>
<form action="/https/github.com/login" method="POST">
<input type="text" name="username" placeholder="Username" /><br />
<input type="password" name="password" placeholder="Password" /><br />
<input type="submit" value="Login" />
</form>
</body>
</html>
'''
);
});
route('POST', '/login', (req, res) {
res.write("Hello ${req.dataMap['username']}");
});
start(7000);
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