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

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.

主站蜘蛛池模板: 乌鲁木齐县| 昭通市| 汉沽区| 尉犁县| 开封市| 准格尔旗| 东山县| 泸水县| 白玉县| 建湖县| 万安县| 精河县| 长子县| 德江县| 永和县| 乌兰县| 政和县| 化州市| 治多县| 北流市| 澄江县| 荥经县| 河北区| 元氏县| 牡丹江市| 上高县| 冀州市| 怀来县| 磐石市| 会昌县| 林州市| 临猗县| 河北区| 栾城县| 厦门市| 两当县| 乐山市| 尤溪县| 赣榆县| 西青区| 上林县|