Skip to content

Commit e993300

Browse files
committed
Update the readme to reflect new API
1 parent ece9c18 commit e993300

File tree

1 file changed

+9
-16
lines changed

1 file changed

+9
-16
lines changed

README.md

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,8 @@
88

99
A powerful routing framework and requests/responses handler for PHP
1010

11-
WaterPipe is a library which allows you to handle easily HTTP requests and responses with PHP, giving you all the power to build a fully RESTful API, to create a routing framework for your web application, etc...
11+
WaterPipe is a library which allows you to easily handle HTTP requests and responses with PHP, giving you all the power
12+
to build a fully RESTful API, to create a routing framework for your web application, etc...
1213

1314
## Example
1415

@@ -28,7 +29,7 @@ $root = new WaterPipe;
2829

2930
// Add a new route to the pipe with HTTP GET method (the home page)
3031
$root->get("/", function (Request $req, Response $res) {
31-
$res->sendHtml("<b>Welcome to my web app !</b>");
32+
$res->sendHtml("<b>Welcome to my web app !</b> <a href=\"/login\">Click here to login</a>");
3233
});
3334

3435
// Add a new route to the pipe with HTTP GET method (the login page)
@@ -50,12 +51,8 @@ $root->post("/login", function (Request $req, Response $res) {
5051
"success" => true
5152
));
5253
} else {
53-
$header = new ResponseHeader;
54-
$header->setLocation("/members/{$username}");
55-
56-
// Overwrite response header for redirection
57-
$res->setHeader($header);
58-
$res->send();
54+
// Redirect the user to the members page
55+
$res->redirect("/members/{$username}");
5956
}
6057
} else {
6158
// Checks if the client access this route with an AJAX request
@@ -64,12 +61,8 @@ $root->post("/login", function (Request $req, Response $res) {
6461
"success" => false
6562
));
6663
} else {
67-
$header = new ResponseHeader;
68-
$header->setLocation("/login");
69-
70-
// Overwrite response header for redirection
71-
$res->setHeader($header);
72-
$res->send();
64+
// Redirect the user to the members page
65+
$res->redirect("/login");
7366
}
7467
}
7568
});
@@ -92,7 +85,7 @@ $root->run();
9285

9386
- Highly designed to quickly create routes for MVC applications and REST services ;
9487
- Object Oriented HTTP [requests](https://github.com/ElementaryFramework/WaterPipe/blob/master/src/WaterPipe/HTTP/Request/Request.php) and [responses](https://github.com/ElementaryFramework/WaterPipe/blob/master/src/WaterPipe/HTTP/Response/Response.php) management ;
95-
- Full support for HTTP methods: GET, POST, PUT and DELETE (more HTTP methods wil be added) ;
88+
- Full support for HTTP methods: GET, POST, PUT, DELETE, HEAD and PATCH ;
9689
- Easily handle common HTTP errors (404, 500, etc...) ;
9790
- Designed to work with frontend frameworks like React.js, AngularJS, Vue.js, etc... with AJAX support
9891

@@ -116,6 +109,6 @@ New to **WaterPipe** ? Learn how to build routing frameworks and REST services b
116109

117110
## License
118111

119-
&copy; Copyright 2018-2019 Aliens Group, Inc.
112+
&copy; Copyright 2018-2019 Aliens Group.
120113

121114
Licensed under MIT ([read license](https://github.com/ElementaryFramework/WaterPipe/blob/master/LICENSE))

0 commit comments

Comments
 (0)