上QQ阅读APP看书,第一时间看更新
Running the code
We can run the program directly using the run command:
go run customMux.go
Now, let us fire two CURL commands and see the output:
curl -X GET http://localhost:8000/randomFloat
curl -X GET http://localhost:8000/randomInt
The responses will be:
0.6046602879796196
87
Your response may change due to the random number generator.
We saw how we can create a URL router with basic Go constructs. Now we are going to look at a few popular URL routing frameworks that are widely used by the Go community for their API servers.