官术网_书友最值得收藏!

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.

主站蜘蛛池模板: 秦安县| 湘潭市| 辛集市| 九寨沟县| 吉林省| 宜章县| 石阡县| 岐山县| 偏关县| 伊金霍洛旗| 策勒县| 安图县| 溧水县| 资阳市| 嘉峪关市| 方山县| 蓝山县| 鄢陵县| 郓城县| 资中县| 韶关市| 临沂市| 武夷山市| 乌海市| 汉沽区| 柳江县| 新津县| 白山市| 达拉特旗| 宁海县| 涞水县| 冕宁县| 克山县| 荣昌县| 锡林郭勒盟| 府谷县| 闻喜县| 兴国县| 锦屏县| 青川县| 分宜县|