Grokking Advanced Go
0% completed
Testing HTTP Handlers
Output:
status: 200 type: application/json body: {"id":1001,"customer":"Ada","paid":true}
This program calls an HTTP handler and reads its full response, and it opens no port and starts no server. An HTTP handler is an ordinary function that receives a request and a ResponseWriter, so a test can call it directly with values of those two types. The package net/http/httptest provides both of them.
This is the one program in this chapter that the player can run, because it needs only one file
.....
.....
.....
Like the course? Get enrolled and start learning!
Reading Progress
0%