Skip to content

Commit

Permalink
Update README.md
Browse files Browse the repository at this point in the history
  • Loading branch information
crookse authored Feb 25, 2019
1 parent 1ffb305 commit d9eaba8
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,16 @@ import Drash from "https://raw.githubusercontent.com/crookse/deno-drash/master/m

/** Define an HTTP resource that handles HTTP requests to the / URI */
export default class HomeResource extends Drash.Http.Resource {
static paths = ["/", "/:name"];
static paths = ["/"];

/**
* Handle GET requests.
*/
public GET() {
this.response.body = `Hello, ${
this.request.path_params.name ? this.request.path_params.name : "world"
this.request.url_query_params.name
? this.request.url_query_params.name
: "world"
}!`;

return this.response;
Expand All @@ -70,9 +72,9 @@ export default class HomeResource extends Drash.Http.Resource {
*/
public POST() {
this.response.body = "POST request received!";
if (this.request.path_params.name) {
if (this.request.url_query_params.name) {
this.response.body = `Hello, ${
this.request.path_params.name
this.request.url_query_params.name
}! Your POST request has been received!`;
}

Expand Down Expand Up @@ -111,9 +113,9 @@ $ deno app.ts --allow-net
_Note: I recommend using [Postman](https://www.getpostman.com/) to make these requests. It's fast and versatile for web development._

- GET `localhost:8000/`
- GET `localhost:8000/:name`
- GET `localhost:8000?name=Thor`
- POST `localhost:8000/`
- POST `localhost:8000/:name`
- POST `localhost:8000?name=Hulk`

---

Expand Down

0 comments on commit d9eaba8

Please sign in to comment.