Building RESTful Web services with Go
上QQ阅读APP看书,第一时间看更新

Running the code

Let us fire a CURL request and see what the response is for various routes:

go run customMux.go

Now, fire up a shell or browser to see the server in action. Here, I use the CURL request:

curl -X GET http://localhost:8000/

The response is:

Your random number is: 0.096970

Use Ctrl + C or Cmd + C to stop your Go server. If you are running it as a background process, use pgrep go to find the processID and kill it using kill pid.