Debugging using the curl command in the Terminal

Another tool is the curl command that you can use to make HTTP requests in the Terminal.

Run your helloWorld application for Vapor with curl:

$ curl "http://localhost:8080/student/Jane"

Here is the output you expected:

The student Jane's GPA is 3.91

When verbose mode is enabled with the -v flag, curl will give out more information on the HTTP request and response:

$ curl -v "http://localhost:8080/student/Jane"
* Trying ::1...
* TCP_NODELAY set
* Connected to localhost (::1) port 8080 (#0)
> GET /student/Jane HTTP/1.1
> Host: localhost:8080
> User-Agent: curl/7.55.1
> Accept: */*
>
< HTTP/1.1 200 OK
< content-type: text/plain; charset=utf-8
< content-length: 30
< date: Wed, 21 Nov 2018 06:46:44 GMT
<
* Connection #0 to host localhost left intact
The student Jane's GPA is 3.91

The curl command is extremely powerful. As you'll see in the next chapter, you can specify a curl command with HTTP POST and JSON data:

$ curl --header "Content-Type: application/json"   --request POST   --data '{"id":"2","title":"New Test","content":"New Content"}'   http://localhost:8080/journal/